日期:2014-05-17 浏览次数:20405 次
作者:zhanhailiang 日期:2013-03-19
include(),require()语句包含并运行指定文件。 这两种结构除了在如何处理失败之外完全一样。
include()产生一个警告而require()则导致一个致命错误。换句话说,如果想在遇到丢失文件时停止处理页面就用 require()。include()就不是这样,脚本会继续运行
例1:include()产生一个Warning而require()则导致一个Fatal error。
zhanhailiang@linux-06bq:~> php -r "include('a.php');" Warning: include(a.php): failed to open stream: No such file or directory in Command line code on line 1 Warning: include(): Failed opening 'a.php' for inclusion (include_path='.:/usr/local/services/phplib/src:/usr/local/services/phplib/inc:/usr/local/services/php/lib/php') in Command line code on line 1 zhanhailiang@linux-06bq:~