note 98539 added to function.include
| From: | BigueNique at yahoo dot ca | Date: | Tue, 22 Jun 2010 00:34:14 +0000 |
| Subject: | note 98539 added to function.include | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-170361@lists.php.net to get a copy of this message | ||
In response to rich dot lovely at klikzltd dot co dot uk
(17-Jul-2008 08:20): "I needed a way of include()ing a php page from a MySQL database..."
To simulate inclusion of text as PHP source, try out this:
<?php
echo eval("?>$text<?");
?>
Example:
<?php
$text = '<?php
/**
* This is a test
*/
$a=array("One","Two","Three","Four");
?>
<html>
<body>
<? foreach($a as $s) { ?>
<div><?=$s;?></div>
<? } ?>
</body>
</html>';
echo eval("?>$text<?");
?>
Outputs:
<html>
<body>
<div>One</div>
<div>Two</div>
<div>Three</div>
<div>Four</div>
</body>
</html>
It will even tell you accurately at which line of the source text an error occurs.
SECURITY WARNING: make 100% sure you totally control the source of the eval()'d text when doing
this!
----
Server IP: 69.147.83.197
Probable Submitter: 216.239.75.8
----
Manual Page -- http://www.php.net/manual/en/function.include.php
Edit -- https://master.php.net/note/edit/98539
Del: integrated -- https://master.php.net/note/delete/98539/integrated
Del: useless -- https://master.php.net/note/delete/98539/useless
Del: bad code -- https://master.php.net/note/delete/98539/bad+code
Del: spam -- https://master.php.net/note/delete/98539/spam
Del: non-english -- https://master.php.net/note/delete/98539/non-english
Del: in docs -- https://master.php.net/note/delete/98539/in+docs
Del: other reasons-- https://master.php.net/note/delete/98539
Reject -- https://master.php.net/note/reject/98539
Search -- https://master.php.net/manage/user-notes.php