Re: eval in php-module

From: Date: Sat, 07 Oct 2000 15:53:38 +0000
Subject: Re: eval in php-module
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-34441@lists.php.net to get a copy of this message
zend_eval_string() is the right function; However, if you pass it a non-NULL retval, zend_eval_string() implicitly adds a 'return' statement before your code. So, what happens is that 'return $test=123;;' is valid, and would work fine as you expect. However, 'return $test=123; $test=345;;' wouldn't perform as you expected. In short, you should supply a NULL return value, if you want to supply a statement (as opposed to an expression). Zeev At 18:10 07/10/2000, Matthias Winkelmann wrote:
Hi! For a current project I am working on a custom module for php4. Unfortunately, I am having a problem trying to evalute php code in this module. I need a function that basically replicates the eval() statement from php with some minor changes. I tried 'zend_eval_string("$test = 123;", &retval ELS_DC);', wich workds, but only for simple statements. Others, such as "$test = 123; $test2= 345;" do not work, nor does the echo construct. Is zend_eval_string the right function for this purpose and what is the exact syntax? Where can I find the implementation of eval() in the php source? What would be the best way to implement such a function? Please cc: to kr@someon.com since I am currently not subscribed to the list. Regards, --kr -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net For additional commands, e-mail: php-dev-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net
-- Zeev Suraski <zeev@zend.com> http://www.zend.com/

« previous php.dev (#34441) next »