“做”是保留关键字:http://www.php.net/manual/en/reserved.keywords.php
在同一页面,在评论中,你看到一个用户提解决的办法。请记住,这个方法必须小心使用:
// Now define a __call() method (requires PHP > 5.2.3 to take effect)
public function __call($func, $args)
{
switch ($func)
{
case 'list':
return $this->ls((isset($args[0]))? $args[0]: null);
break;
case 'unset':
return $this->rm($args[0]);
break;
default:
trigger_error("Call to undefined method ".__CLASS__."::$func()", E_USER_ERROR);
die();
}
所以你看,你可以通过使用__call
超负荷使用任何类do
方法(或其他一些保留字)。从外部看,这种方法与传统定义的方法无法区分。
你应该把你的问题,你的目的是创建一个模拟做目的。 – webbiedave