php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34833 Incorrect this assignment
Submitted: 2005-10-11 21:18 UTC Modified: 2005-10-11 22:39 UTC
From: stochnagara at hotmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.1.0RC1 OS: windows xp
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:
36 + 43 = ?
Subscribe to this entry?

 
 [2005-10-11 21:18 UTC] stochnagara at hotmail dot com
Description:
------------
$this is assigned incorrectly. See the sample code below.

Reproduce code:
---------------
<?

class abc {
 function a() { echo "abc::a\n"; $this->b(); }
 function b() { echo "abc::b\n"; }
}

class def {
 function c() { echo "def::c\n"; abc::a(); }
}

$test = new def();
$test->c();


Expected result:
----------------
def::c abc::a
some error message

Actual result:
--------------
def::c abc::a
Fatal error: Call to undefined method def::b() in ...php on line 4


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-11 21:26 UTC] tony2001@php.net
Declare static methods as static, this way there won't be $this at all.
This is done to keep BC with PHP4 and won't change in the nearest future.
 [2005-10-11 22:39 UTC] stochnagara at hotmail dot com
Actually "Won't Fix" is a better bug status since it is not an expected behaviour. I expect an error message for example:) But that's not important.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 03 13:01:33 2024 UTC