#38697 [Opn->Bgs]: access method from other object with call_user_func

From: Date: Mon, 04 Sep 2006 08:36:42 +0000
Subject: #38697 [Opn->Bgs]: access method from other object with call_user_func
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-101690@lists.php.net to get a copy of this message
ID: 38697 Updated by: tony2001@php.net Reported By: totol at tele2 dot fr -Status: Open +Status: Bogus Bug Type: Class/Object related Operating System: Windows XP PHP Version: 4.4.4 New Comment: PHP4: hello Notice: Undefined variable: this in /tmp/2.php on line 14 PHP5: Strict Standards: Non-static method myClass2::method() should not be called statically, assuming $this from incompatible context in /tmp/2.php on line 6 hello Strict Standards: Non-static method myClass2::method() cannot be called statically in /tmp/2.php on line 9 Strict Standards: Non-static method myClass2::method() cannot be called statically in /tmp/2.php on line 9 Previous Comments: ------------------------------------------------------------------------ [2006-09-03 08:52:11] totol at tele2 dot fr Description: ------------ if you call a static method with call_user_func in an object, you don't have access to var of the caller object, see code bellow Reproduce code: --------------- class myClass { var $myVar="hello"; function staticCall(){ myClass2::method(); } function calluserCall(){ call_user_func(array('myClass2','method')); } } class myClass2{ function method(){ echo $this->myVar; } } $test=new myclass(); $test->staticCall(); //return 'hello' $test->calluserCall(); //return nothing Expected result: ---------------- $test->staticCall(); //return 'hello' $test->calluserCall(); //return nothing ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38697&edit=1

« previous php.bugs (#101690) next »