|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-04-10 03:37 UTC] david71rj at gmail dot com
Description: ------------ If I use public method as static in a method of a second function, this send $this from second class, don't of the first. Test script: --------------- http://codepad.org/8hW4Qtbo Expected result: ---------------- array 0 => string 'static' (length=6) 1 => int 1 array 0 => string 'object' (length=6) 1 => object(test)[2] 2 => int 1 array 0 => string 'static' (length=6) 1 => int 1 array 0 => string 'object' (length=6) 1 => object(test)[3] <<<<<<<<<<<<<<< OKAY 2 => int 1 Actual result: -------------- array 0 => string 'static' (length=6) 1 => int 1 array 0 => string 'object' (length=6) 1 => object(test)[2] 2 => int 1 array 0 => string 'static' (length=6) 1 => int 1 array 0 => string 'object' (length=6) 1 => object(test2)[3] <<<<<<<<< WHY "test2" IF DON'T? 2 => int 1 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 24 20:00:01 2025 UTC |
Not make sense, a call static is call static, don't can exist $this. In counterpart, if the user need pass a object reference, he must be to specific how a parameter. public function x($object = null){ if($object && get_class($object) == 'B') { // Now make sense, but not is $this } } Bye.