php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23922 With assert(string): $this unavailable inside of eval() code
Submitted: 2003-05-31 09:48 UTC Modified: 2003-07-03 02:08 UTC
From: dave at codewhore dot org Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2003-05-31 (dev) OS: Linux 2.4
Private report: No CVE-ID: None
 [2003-05-31 09:48 UTC] dave at codewhore dot org
Hi:

Given the following script, which uses assert to eval() a string that references the current class instance:

<?php
  class foo
  {
    var $foo = 1;

    function as_string()
    { assert('$this->foo == 1'); }

    function as_expr()
    { assert($this->foo == 1); }
  }

  $foo = new foo();
  $foo->as_expr();
  $foo->as_string();
?>

PHP 4.3-cvs executes it correctly, but PHP 5.0-cvs with ZE2 fails:

  Fatal error: Using $this when not in object context in
    /home/dave/test.php(8) : assert code on line 1

Is this expected behavior? More specifically, is $this no longer available inside of an eval() on ZE2?     


Thanks in advance,

- Dave

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-03 02:08 UTC] sterling@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Aug 13 18:00:03 2025 UTC