note 20595 added to function.eval

From: Date: Tue, 09 Apr 2002 13:08:18 +0000
Subject: note 20595 added to function.eval
Groups: php.notes 
Request: Send a blank email to php-notes+get-29009@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: 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 http://master.php.net/manage/user-notes.php?action=edit+20595 http://master.php.net/manage/user-notes.php?action=delete+20595 http://master.php.net/manage/user-notes.php?action=reject+20595

« previous php.notes (#29009) next »