PHP中include和require有什么区别
本文主要介绍"PHP中include和require有什么区别",希望能够解决您遇到有关问题,下面我们一起来看这篇 "PHP中include和require有什么区别" 文章。
PHP include vs. require
require 语句同样用于向 PHP 代码中引用文件。
不过,include 与 require 有一个巨大的差异:如果用 include 语句引用某个文件并且 PHP 无法找到它,脚本会继续执行:
实例
<html> <body> <h1>Welcome to my home page!</h1> <?php include 'noFileExists.php'; echo "I have a $color $car."; ?> </body> </html>
如果我们使用 require 语句完成相同的案例,echo 语句不会继续执行,因为在 require 语句返回严重错误之后脚本就会终止执行:
实例
<html> <body> <h1>Welcome to my home page!</h1> <?php require 'noFileExists.php'; echo "I have a $color $car."; ?> </body> </html>
关于 "PHP中include和require有什么区别" 就介绍到这。希望大家多多支持编程宝库。
本文主要介绍"PHP中include语句的用法示例",希望能够解决您遇到有关问题,下面我们一起来看这篇 "PHP中include语句的用法示例" 文章。PHP include 实例例子 1假设我们有一个 ...