note 32038 added to function.eval

From: Date: Wed, 14 May 2003 14:10:56 +0000
Subject: note 32038 added to function.eval
Groups: php.notes 
Request: Send a blank email to php-notes+get-47957@lists.php.net to get a copy of this message
An example of eval within a function within a class sitting on PEAR DB whose purpose is to push onto a result array named: result_ appended with a parameter key. function set_result_array($fn_request_key = '[DEFAULT]', $fn_result) { $target_array_string = 'result_'.$fn_request_key; // eval ("global \$\$target_array_string;"); eval("\$target_array =& this->\$target_array_string;"); if (!is_array($target_array)) { $target_array = array(); } return array_push($target_array, $fn_result); } What does this illustrate? An example of using eval to create a reference to an object member by reference (=&). The eval ("global ....) line is commented out as I couldn't get this to work for some reason. -- http://www.php.net/manual/en/function.eval.php http://master.php.net/manage/user-notes.php?action=edit+32038 http://master.php.net/manage/user-notes.php?action=delete+32038 http://master.php.net/manage/user-notes.php?action=reject+32038

« previous php.notes (#47957) next »