Created
January 6, 2011 15:17
-
-
Save mscottford/768002 to your computer and use it in GitHub Desktop.
Fun with PHP's $this variable (PHP 5.2)
This file contains hidden or 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
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