Created
February 16, 2019 12:26
-
-
Save yyong37/2a4b3831a709cbcbc6fd6cd17395a731 to your computer and use it in GitHub Desktop.
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
<?php | |
// we can use this, make our code simple and short. | |
class MethodTest | |
{ | |
public function __call($name, $arguments) | |
{ | |
// Note: value of $name is case sensitive. | |
echo "Calling object method '$name' " | |
. implode(', ', $arguments). "\n"; | |
} | |
/** As of PHP 5.3.0 */ | |
public static function __callStatic($name, $arguments) | |
{ | |
// Note: value of $name is case sensitive. | |
echo "Calling static method '$name' " | |
. implode(', ', $arguments). "\n"; | |
} | |
} | |
$obj = new MethodTest; | |
$obj->runTest('in object context'); | |
MethodTest::runTest('in static context'); // As of PHP 5.3.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment