php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #517 eval() is not a function
Submitted: 1998-07-07 11:16 UTC Modified: 1998-07-07 11:34 UTC
From: kk at shonline dot de Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 3.0 Final Release OS: Solaris 2.5.1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: kk at shonline dot de
New email:
PHP Version: OS:

 

 [1998-07-07 11:16 UTC] kk at shonline dot de
eval() is not a function (despite the required notation), thus I can't write

$var = "o->slot[10]";
$a = eval("\$".$var.";");

to access $o->slot[10]. I also can't use $$var. I could use a temporary variable
within the eval statement, but this would create a copy of $o->slot[10], which
is no good, if $o->slot[10] is a slice of a multidimensional array.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-07-07 11:34 UTC] zeev
eval() is indeed not a function, and it's never going to be a function either.
Think about it for some more time, and you'll see that what you suggested makes no sense.
eval() is comparable to include() or require(), or even exec(). 
It executes code.  It doesn't evaluate expressions and
returns their value, it evaluates code and executes it.

What you want instead of 
$foo = eval($something);
is
eval("$foo=$something;");

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC