我不能做这样的事吗?
try {
require_once( '/includes/functions.php' );
}
catch(Exception $e) {
echo "Message : " . $e->getMessage();
echo "Code : " . $e->getCode();
}
没有回显错误,服务器返回 500。
你可以这样做include_once
or file_exists
:
try {
if (! @include_once( '/includes/functions.php' )) // @ - to suppress warnings,
// you can also use error_reporting function for the same purpose which may be a better option
throw new Exception ('functions.php does not exist');
// or
if (!file_exists('/includes/functions.php' ))
throw new Exception ('functions.php does not exist');
else
require_once('/includes/functions.php' );
}
catch(Exception $e) {
echo "Message : " . $e->getMessage();
echo "Code : " . $e->getCode();
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)