PHP 4.0 Bug #5435: Request to update eval() or create new function.
| From: | dahamsta at iewebs dot com | Date: | Fri, 07 Jul 2000 13:46:10 +0000 |
| Subject: | PHP 4.0 Bug #5435: Request to update eval() or create new function. | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-23711@lists.php.net to get a copy of this message | ||
From: dahamsta@iewebs.com
Operating system:
PHP version: 4.0.0
PHP Bug Type: Feature/Change Request
Bug description: Request to update eval() or create new function.
Currently, to eval() regular data retrieved from a database or include file, I need to escape from
PHP and re-enter it. For example:
Presume that I have retrieved data from a source, which is equivalent to a regular PHP file
(including plain HTML). To operate eval() on that, and avoid parsing the HTML and thus causing PHP
errors, I need to use a function like this:
function my_eval($my_eval_str) {
$eval_str = "?>";
$eval_str .= $my_eval_str;
$eval_str .= "<?";
return eval($eval_str);
}
This would also make it impossible to access variables in the GLOBAL symbol table, unless I
extract($GLOBALS) into the current sumbol table.
My suggestion is to either add a second eval() function that will operate in this way; or add a
second argument to eval(), such as:
void eval (string code_str, string eval_type);
Where 'code_str' is the same as the current eval() function, and 'eval_type' is
one of two options - one for just PHP code, and one for a string that will contain data escaped from
PHP. The default could be set to the current operation, and the second argument could be optional.
Ta,
adam