這其實是PHP中非常好玩的東西XDDD

class Car{
	function __call($method_name , $arguments){
		echo "This method is '$method_name' and arguments is '".implode(",",$arguments)."'";
	}
	
	//PHP 5.3之後才有支援__call靜態的function
	static function __callStatic($method_name , $arguments){
		echo "This method is '$method_name' and arguments is '".implode(",",$arguments)."'";
	}
}

$obj = new Car();
//當呼叫沒有定義的function時,就會執行__call函式並帶入原本參數
$obj -> gogogo("Hello");

//直接呼叫靜態function
Car::gogogo("EveryBody");

Categories: PHP