我在我的 php 脚本中使用 require_once,我想知道编写代码的正确方法,以便在失败时处理错误。
目前,我只使用 require_once('included_file.php'); 我在想用这个:
if (!@require_once('included_file.php')){
//log error, print nice error message, and exit;
}
这是“好的做法”,还是有不同/更好的方法来做到这一点。我已经阅读了这个页面(http://us3.php.net/manual/en/language.operators.errorcontrol.php)并看到了 OR DIE 的使用,但我只是不确定最好的方法。
谢谢!