「做」是保留關鍵字: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