Created
February 25, 2011 15:19
-
-
Save tildedave/843928 to your computer and use it in GitHub Desktop.
scoping in php for static/non-static methods + inheritance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment