php魔术方法之_call()
2012-07-02 00:05
351 查看
php的魔术方法_call()在调用类中未定义的方法时会自动调用。php.net中代码示例如下:
<?php 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 ?>
相关文章推荐
- php 魔术方法 __call
- PHP魔术方法之__call与__callStatic使用方法
- PHP魔术方法__call
- 跟着百度学PHP[4]OOP面对对象编程-15-魔术方法__call方法
- PHP中的11个魔术方法总结:__construct,、__destruct、__call等
- php深入学习二——魔术方法以及__call的调用
- PHP 魔术方法之__set__get__unset,__isset,__call
- PHP魔术方法之__call与__callStatic方法
- php用魔术方法__call实现类函数重载
- PHP中的__call()魔术方法2
- PHP魔术方法之__call与__callStatic方法
- PHP中的魔术方法总结 :__construct, __destruct , __call, __callStatic,__get, __set, __isset, __uns
- PHP魔术方法__call()篇
- php魔术方法__call
- PHP中的魔术方法:__construct, __destruct , __call,__get, __set, __isset, __unset , __toString, __set,__clone and __autoload
- PHP中的魔术方法总结 :__construct, __destruct , __call, __callStatic,__get, __set, __isset, __unset , __sleep
- PHP中的魔术方法 :__construct, __destruct , __call, __callStatic,__get, __set, __isset, __unset , __sleep,
- PHP中的魔术方法总结 :__construct, __destruct , __call, __callStatic,__get, __set, __isset, __unset , __sleep, __wakeup, __toStr
- PHP中overload __call魔术方法 和引用传递的问题
- php __call()魔术方法介绍