php include include_once require require_once 的区别与联系
一、require 与 include 的区别:
The require() function is identical to include(), except that it handles errors differently. If an error occurs, the include() function generates a warning, but the script will continue execution. The require() generates a fatal error, and the script will stop.
这两个方法基本没有区别,除了在错误处理方面的。如果使用 include 方法出错,这个方法抛出一个warning,不影响程序的继续执行,但是 require 方法产生一个 fatal error,程序运行终止。
二、require 与 require_once 的区别:
The require_once() statement is identical to require() except PHP will check if the file has already been included,and if so, not include (require) it again.
这两个方法的区别在于如果使用 require_once php 会检查需要包含的文件是否已经被包含了,如果是,那么就不会重新包含。