Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:27225 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94339 invoked by uid 1010); 31 Dec 2006 15:00:21 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 94324 invoked from network); 31 Dec 2006 15:00:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Dec 2006 15:00:21 -0000 Received: from [127.0.0.1] ([127.0.0.1:15800]) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ECSTREAM id 0D/11-62355-480D7954 for ; Sun, 31 Dec 2006 10:00:21 -0500 Authentication-Results: pb1.pair.com header.from=devriese@cs.tcd.ie; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=edsko@netsoc.tcd.ie; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain netsoc.tcd.ie from 134.226.83.42 cause and error) X-PHP-List-Original-Sender: edsko@netsoc.tcd.ie X-Host-Fingerprint: 134.226.83.42 spoon.netsoc.tcd.ie Linux 2.6 Received: from [134.226.83.42] ([134.226.83.42:39362] helo=spoon.netsoc.tcd.ie) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 97/D0-62355-10DC7954 for ; Sun, 31 Dec 2006 09:45:22 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by spoon.netsoc.tcd.ie (Postfix) with ESMTP id D77E0544B3 for ; Sun, 31 Dec 2006 14:45:18 +0000 (GMT) Received: from spoon.netsoc.tcd.ie ([127.0.0.1]) by localhost (spoon.netsoc.tcd.ie [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 23304-09 for ; Sun, 31 Dec 2006 14:45:18 +0000 (GMT) Received: by spoon.netsoc.tcd.ie (Postfix, from userid 1025) id B341F54504; Sun, 31 Dec 2006 14:45:18 +0000 (GMT) Date: Sun, 31 Dec 2006 14:45:18 +0000 To: internals@lists.php.net Message-ID: <20061231144518.GB15021@netsoc.tcd.ie> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Operating-System: Linux spoon.netsoc.tcd.ie 2.6.17 User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at spoon.netsoc.tcd.ie Subject: calling zend_eval_string From: devriese@cs.tcd.ie (Edsko de Vries) 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