note 98539 deleted from function.include by danbrown

From: Date: Tue, 22 Jun 2010 00:36:08 +0000
Subject: note 98539 deleted from function.include by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-170362@lists.php.net to get a copy of this message
Note Submitter: BigueNique at yahoo dot ca ---- 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!

« previous php.notes (#170362) next »