|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2000-07-07 15:46 UTC] dahamsta at iewebs dot com
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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 24 11:00:02 2025 UTC |
eval("?>".$my_eval_str); works for me.