Hi,

If I try to call zend_eval_string as follows:

zval* retval;
MAKE_STD_ZVAL(retval);
zend_eval_string("return 5;", retval, "eval'd code" TSRMLS_CC);

I get the following runtime error:

eval'd code(1) : Parse error - syntax error, unexpected T_RETURN

It turns out that zend_eval_string actualy prepends "return " to the
argument to zend_eval_string (zend_execute_API.c, around line 1577),
causing "return return 5;" to be evaluated - hence the error. Why is
that the case? Is there a different function I could call that doesn't
do this? (The problem is that the code will be user-supplied, not
written by be; so to work-around this problem, I'd have to check if the
user-supplied code starts with "return "; if so, remove it, only for it
to be added again by zend_eval_string).

What is the proper solution to this problem?

Thanks in advance,

Edsko

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to