riddhi Posted January 14, 2008 Share Posted January 14, 2008 <?php class A { function foo() { if (isset($this)) { echo '$this is defined ('; echo get_class($this); echo ")\n"; } else { echo "\$this is not defined.\n"; } } } class B { function bar() { A::foo(); } } $a = new A(); $a->foo(); A::foo(); $b = new B(); $b->bar(); B::bar(); ?> In the above what does A::Foo() represents a static method?? is there no declaration difference between the static and the normal method. Quote Link to comment https://forums.phpfreaks.com/topic/85949-static-method-and-normal-method-declaration/ Share on other sites More sharing options...
trq Posted January 14, 2008 Share Posted January 14, 2008 The code above should produce all sorts of errors. <?php class A { static function foo() { if (isset(self)) { echo 'self is defined ('; echo get_class(self); echo ")\n"; } else { echo "\self is not defined.\n"; } } } Quote Link to comment https://forums.phpfreaks.com/topic/85949-static-method-and-normal-method-declaration/#findComment-438812 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.