Home > Backend Development > PHP Tutorial > PHP学习:include()和require()的区别_PHP

PHP学习:include()和require()的区别_PHP

WBOY
Release: 2016-06-01 12:29:41
Original
822 people have browsed it


include()和require()的区别 这相信是PHP中最基本的问题了,也是很多公司面试时必考的题呵呵。

给大家复习一下:

require() :如果文件不存在,会报出一个fatal error.脚本停止执行
include() : 如果文件不存在,会给出一个 warning,但脚本会继续执行

这里特别要注意的是:
使用include()文件不存在时,脚本继续执行,这种情况只出现在PHP 4.3.5之前,这一点,往往被人忽视。

推荐使用require_once()和include_once(),可以检测文件是否有重复包含。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template