<?php
class Man{
public function __call($name,$args){
echo "Calling object method ".$name. ' ' . implode(', ', $args). "\n";
}
}
$obj = new Man();
<span style="font-family:Arial, Helvetica, sans-serif;">$obj->run("in object context");</span>
?>
</pre><pre name="code" class="php">运行结果为:<span style="font-family: Simsun;font-size:14px;">Calling object method run in object context</span>
<span style="font-family: Simsun;font-size:14px;">
</span>
<span style="font-family: Simsun;font-size:14px;">
</span>
<span style="font-family:Simsun;font-size:14px;">__call方法是在实例化对象后,在调用该对象中不存在的方法时自动调用__call方法,一定要记住,方法参数$name,$args为必须</span>