Skip to content

Instantly share code, notes, and snippets.

@mscottford
Created January 6, 2011 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mscottford/768002 to your computer and use it in GitHub Desktop.
Save mscottford/768002 to your computer and use it in GitHub Desktop.
Fun with PHP's $this variable (PHP 5.2)
Interactive shell
php > class Foo {
php { public function invoke() {
php { print(get_class($this));
php { }
php { }
php > class Bar {
php { public function invoker() {
php { $foo = new Foo();
php { $foo->invoke();
php { }
php { public function staticInvoker() {
php { Foo::invoke();
php { }
php { }
php > $bar = new Bar();
php > $bar->invoker();
Foo
php > $bar->staticInvoker();
Bar
php >
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment