Skip to content

Instantly share code, notes, and snippets.

@tildedave
Created February 25, 2011 15:19
Show Gist options
  • Save tildedave/843928 to your computer and use it in GitHub Desktop.
Save tildedave/843928 to your computer and use it in GitHub Desktop.
scoping in php for static/non-static methods + inheritance
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