<?php classMethodTest{ publicfunction__call($name, $arguments){ // Note: value of $name is case sensitive. echo"Triggering __call method when calling method '$name' with arguments '" . implode(', ', $arguments). "'.\n"; } }
$obj = new MethodTest; $obj->callTest('arg1','arg2');
/*运行结果 Triggering __call method when calling method 'callTest' with arguments 'arg1, arg2'. */ ?>
<?php classMethodTest{ publicstaticfunction__callStatic($name, $arguments){ // Note: value of $name is case sensitive. echo"Triggering __call method when calling method '$name' with arguments '" . implode(', ', $arguments). "'.\n"; } }
MethodTest::callStaticTest('arg3','arg4'); // As of PHP 5.3.0 /*运行结果 Triggering __call method when calling method 'callStaticTest' with arguments 'arg3, arg4'. */ ?>