note 56829 deleted from function.eval by mazzanet
| From: | mazzanet@php.net | Date: | Fri, 16 Sep 2005 06:21:13 +0000 |
| Subject: | note 56829 deleted from function.eval by mazzanet | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-95264@lists.php.net to get a copy of this message | ||
Note Submitter: sadi at unicornsoftbd dot com
----
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);
?>