php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31888 return in eval does not return
Submitted: 2005-02-08 21:20 UTC Modified: 2005-02-08 21:52 UTC
From: quinn at quinn dot student dot utwente dot nl Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.0.3 OS: Linux Gentoo 2.4.28
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: quinn at quinn dot student dot utwente dot nl
New email:
PHP Version: OS:

 

 [2005-02-08 21:20 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-08 21:44 UTC] quinn at quinn dot student dot utwente dot nl
Sorry to have bothered anyone with this :( i forgot the scope i should have returned the value in the eval.

like:
eval("return text();");
 [2005-02-08 21:45 UTC] quinn at quinn dot student dot utwente dot nl
Closed
 [2005-02-08 21:52 UTC] quinn at quinn dot student dot utwente dot nl
should be bogus
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Dec 06 18:00:01 2025 UTC