note 20595 modified in function.eval by vincent

From: Date: Sat, 30 Aug 2003 21:03:52 +0000
Subject: note 20595 modified in function.eval by vincent
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-55366@lists.php.net to get a copy of this message
My external filename (TableStart.htm) contains something like: <table border=0 width="<?PHP echo $myvar ?>"> Now I had a routine which drew a box arround all my HTML. Of course I couldn't pass all my variables so I used eval() to declare my variables like this: Original routine: <?php global $myvar; $string = implode ('', @file('TableStart.html')); $string = "?>" . $string . "<?PHP "; DoBox ($string, "\$myvar"); function DoBox($body, $extravars = "") { if (!empty($extravars)) eval("global ".$extravars.";"); /* draw start of box */ echo "<table><tr><td>"; /* draw the body */ eval($body); /* draw end of box */ echo "</td></tr></table>"; } ?> Neat! --was-- My external filename (TableStart.htm) contains something like: <table border=0 width="<?PHP echo $myvar ?>"> Now I had a routine which drew a box arround all my HTML. Of course I couldn't pass all my variables so I used eval() to declare my variables like this: Original routine: global $myvar; $string = implode ('', @file('TableStart.html')); $string = "?>" . $string . "<?PHP "; DoBox ($string, "\$myvar"); function DoBox($body, $extravars = "") { if (!empty($extravars)) eval("global ".$extravars.";"); /* draw start of box */ echo "<table><tr><td>"; /* draw the body */ eval($body); /* draw end of box */ echo "</td></tr></table>"; } Neat! http://www.php.net/manual/en/function.eval.php

« previous php.notes (#55366) next »