我面臨一個很奇怪的錯誤,雖然它似乎我已經做了所有需要PHP致命錯誤:類「X」未找到
錯誤:PHP Fatal error: Class 'Login' not found
代碼:
<?php
//Includes...
require_once(__DIR__ . "/base/request.abstract.php");
//Entry point...
try {
//What should i do ? the class is in the same file so what to do so php recognize it ?
echo (new Login($_REQUEST['request']))->processRequest();
} catch (Exception $e) {
echo json_encode(array('error' => $e->getMessage()));
}
//Implementation...
class Login extends RequestAbstract
{
public function processRequest()
{
}
}
「看來我已經完成了所有的要求」顯然不是,因此錯誤。不知道還有什麼我們可以說 –
[看看這個問題](http://stackoverflow.com/questions/3458756/does-the-order-of-class-definition-matter-in-php) –
這就是爲什麼我說'看起來' –