我試圖捕獲異常,但不可能,只是正在錯誤消息PHP異常不要再追
try{
echo 'test';
require_once "jj.php";
return true;
} catch (Exception $ex) {
throw new Exception("error occured");
}
Warning: require_once(jj.php): failed to open stream: No such file or directory in C:\xampp\htdocs\corporate-wellness\module\Survey\src\Survey\Repository\QuestionRepository.php on line
退房['file_exists'(HTTP:// PHP .net/manual/en/function.file-exists.php)並觸發/拋出你自己的錯誤/異常。 – Script47
[this]的副本(http://stackoverflow.com/questions/5369488/try-catch-cannot-work-with-require-once-in-php) – DevDonkey