Last active
December 17, 2015 18:49
-
-
Save chaitanyakuber/5655854 to your computer and use it in GitHub Desktop.
ooh, can use __call in php to catch missing methods, great pattern when refactoring
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
class foo | |
{ | |
public function __call($name, $arguments) | |
{ | |
// Note: value of $name is case sensitive. | |
echo "Calling object method '$name' " | |
. implode(', ', $arguments). "\n"; | |
} | |
public function hello() | |
{ | |
echo "hello"; | |
} | |
} | |
$f = new foo(); | |
$f->getLost(); | |
$f->hello(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment