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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
47 - 1 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Sun Jun 16 08:01:29 2024 UTC