#31888 [Opn]: return in eval does not return

From: Date: Tue, 08 Feb 2005 20:44:57 +0000
Subject: #31888 [Opn]: return in eval does not return
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-73660@lists.php.net to get a copy of this message
ID: 31888 User updated by: quinn at quinn dot student dot utwente dot nl Reported By: quinn at quinn dot student dot utwente dot nl Status: Open Bug Type: *General Issues Operating System: Linux Gentoo 2.4.28 PHP Version: 5.0.3 New Comment: Sorry to have bothered anyone with this :( i forgot the scope i should have returned the value in the eval. like: eval("return text();"); Previous Comments: ------------------------------------------------------------------------ [2005-02-08 21:20:26] quinn at quinn dot student dot utwente dot nl Description: ------------ According to the documentation a return in eval should return the value passed to the return statement. This works fine outside functions or classes. But when you want to eval a function or a function in a class this does not work. Reproduce code: --------------- class aap{ static function aap1(){ return 'aap'; } } function text(){ return 'text'; } $a = eval('text();'); echo $a; $b = eval("return 'output';"); echo $b; $c = eval("aap::aap1();"); echo $c; Expected result: ---------------- text output aap Actual result: -------------- output ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=31888&edit=1

« previous php.bugs (#73660) next »