0

我有个问题。Throwable 不会为 require 或 include 函数返回异常。有没有办法“修复”它?代码:

try {
    include 'non-existent-file.php';
    #require 'non-existent-file.php';
} catch (\Throwable $ex) {
    die('include error');
}

预先感谢您的帮助。

4

1 回答 1

0

你有没有想过使用file_exists ( string $filename )...

if ( file_exists('non-existent-file.php') === true)   {
    include 'non-existent-file.php';
} 
else {
    die('include error');
}
于 2017-06-03T19:36:27.087 回答