PHP对象不存在call()、callStatic()
call()
在对象中调用一个不可访问方法时,__call()会被调用
callStatic()
在静态上下文中调用一个不可访问方法时,__callStatic()会被调用
<?php
class MethodTest
{
public function __call($name, $arguments)
{
echo "Calling object method '$name' "
. implode(', ', $arguments). "\n";
}
public static function __callStatic($name, $arguments)
{
echo "Calling static method '$name' "
. implode(', ', $arguments). "\n";
}
}
$obj = new MethodTest;
//Calling object method 'runTest' in object context
$obj->runTest('in object context');
//Calling static method 'runTest' in static context
MethodTest::runTest('in static context');
?>原文链接:https://www.qiquanji.com/post/7987.html
本站声明:网站内容来源于网络,如有侵权,请联系我们,我们将及时处理。
版权声明
本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。
