-4
public function processApi(){
$func = strtolower(trim(str_replace("/","",$_SERVER['REQUEST_URI']))); //echo $func;
if((int)method_exists($this,$func) > 0)
$this->$func();
else
$this->response('',404);
echo '404'; // If the method not exist with in this class, response would be "Page not found".
}
感謝回答。 ,但仍然錯誤。 錯誤是:意外'' – jerry
如果您使用MVC結構,所以得到錯誤,但使用核心oops沒有得到error.so如果您將使用MVC嘗試$ this-> router-> fetch_method();替換$ _SERVER ['REQUEST_URI'] –
我使用了核心代碼。 – jerry