note 43191 added to function.eval

From: Date: Sat, 12 Jun 2004 21:15:35 +0000
Subject: note 43191 added to function.eval
Groups: php.notes 
Request: Send a blank email to php-notes+get-70990@lists.php.net to get a copy of this message
"Bart Koelman" 's example above (OutputPhpDocument), though thouroughly functional , would benefit by using the "extract()" function in lieu of his variable exporting solution. I.e.: <? reset ($GLOBALS); while (list ($key, $val) = each ($GLOBALS)) { eval("\$" . "\$key = \"$val\";"); } ?> Can be replaced with a single line: <?extract($GLOBALS, EXTR_SKIP | EXTR_REFS);?> Addtionally, this latter alternative will load the global variables as references instead of 'copies'. (Meaning that if a value is altered inside the function , that modification will also be effected outside of the OutputPhpDocument() function. ---- Manual Page -- http://www.php.net/manual/en/function.eval.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+43191 Delete -- http://master.php.net/manage/user-notes.php?action=delete+43191&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+43191&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#70990) next »