note 56829 added to function.eval
| From: | sadi at unicornsoftbd dot com | Date: | Fri, 16 Sep 2005 05:02:37 +0000 |
| Subject: | note 56829 added to function.eval | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-95260@lists.php.net to get a copy of this message | ||
This is an example how to read a php file from disk and use in eval() function. This uses the
concept i gave in my previous post.
<?php
$code=file_get_contents("file.php");
$code=' ?> '.$code.' <?php ';
eval($code);
?>
here the concept that as php assumes that the code passed as a parameter of evel() is already in php
block. so you need close the close the php tag and reopen it by the line
$code=' ?> '.$code.' <?php ';
as file.php should contain a starting and ending php tag.
this concept will work for HTML file too. Here the sample code will the same except the change in
the file name.
<?php
$code=file_get_contents("file.htm");
$code=' ?> '.$code.' <?php ';
eval($code);
?>
----
Manual Page -- http://www.php.net/manual/en/function.eval.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+56829
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56829&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56829&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56829&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56829&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56829&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+56829&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56829&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+56829&report=yes
Search -- http://master.php.net/manage/user-notes.php