note 56641 added to function.eval

From: Date: Sat, 10 Sep 2005 17:23:55 +0000
Subject: note 56641 added to function.eval
Groups: php.notes 
Request: Send a blank email to php-notes+get-94992@lists.php.net to get a copy of this message
to load a php file to a variable then execute it, try this <?php $code=file_get_contents("file.php"); $code=str_replace('<'.'?php','<'.'?',$code); $code='?'.'>'.trim($code).'<'.'?'; eval($code); ?> using < ?php within eval does not work, but < ? does. in case there is html in the file loaded, the script doesn't remove the < ?php and ? >, but insted adds ? > and < ? around the code loaded from the file. it's simple and works very well. I also broke up the tags in the 3rd and 4th lines of code to keep from having problems if the lines are commented out. ---- Manual Page -- http://www.php.net/manual/en/function.eval.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+56641 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56641&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56641&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56641&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56641&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56641&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56641&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+56641&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#94992) next »