#34833 [Opn->Bgs]: Incorrect this assignment

From: Date: Tue, 11 Oct 2005 19:26:05 +0000
Subject: #34833 [Opn->Bgs]: Incorrect this assignment
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-86428@lists.php.net to get a copy of this message
ID: 34833 Updated by: tony2001@php.net Reported By: stochnagara at hotmail dot com -Status: Open +Status: Bogus Bug Type: Class/Object related Operating System: windows xp PHP Version: 5.1.0RC1 New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2005-10-11 21:18:27] 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=34833&edit=1

« previous php.bugs (#86428) next »