|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-09-09 10:46 UTC] stas@php.net
[2002-09-26 19:55 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 18 15:00:01 2025 UTC |
I have a problem with static method usage (Classname::methodname()) here are two classes, for example: <code> class test1 { var $prop1; var $prop2; function test1($val1, $val2){ $this->prop1 = $val1; $this->prop2 = $val2; } function test_method(){ if($this){ var_dump($this); } else { echo "do something" } } } class test2 { function test2(){ } function run(){ test1::test_method(); } } t_obj = new test2(); t_obj->run(); </code> I will always get output of var_dump, because in method of test1 test_method() $this is always set and it is reference or copy of initialized test2 class Check of $this in test_method is required to check if it is static call or from this object, but it does not work, I think this is not correct behavior