ID: 5435 Comment by: a at b dot c dot de Reported By: dahamsta at iewebs dot com Status: Open Bug Type: Feature/Change Request PHP Version: 4.0.0 New Comment:
eval("?>".$my_eval_str); works for me. Previous Comments: ------------------------------------------------------------------------ [2002-06-08 09:59:23] bigredlinux at yahoo dot com Oh, this would be a great feature. One thing this would add is the ability to run an xml string with processing instructions right through php, by just passing it to eval and assuming that eval knows it is going to have php somewhere in it. Very nice feature request! ------------------------------------------------------------------------ [2000-07-07 15:46:10] 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=5435&edit=1