php include 和 require区别
程序员文章站
2022-05-03 19:13:24
...
刚接触php不久,碰到include和require, 在网上查了很久,很多人也做了比较,有些不大正确,有误导之嫌,最权威的正确的答案在这里:http://cn.php.net/manual/zh/function.include.php。
看了如果还不明白的话,我做了以下测试,
情况一:
<?php
include("./est.php"); // est.php不存在
echo "<br>continue...";
?>
测试结果:
Warning: include(./est.php): failed to open stream: No such file or directory in .../test1.php on line 2 Warning: include(): Failed opening './est.php' for inclusion (include_path='.:/usr/local/Cellar/php/5.3.10/lib/php') in .../test1.php on line 2
continue...
情况二:
<?php
require("./est.php");
echo "<br>continue...";
?>
测试结果:
Warning: require(./est.php): failed to open stream: No such file or directory in .../test1.php on line 2 Fatal error: require(): Failed opening required './est.php' (include_path='.:/usr/local/Cellar/php/5.3.10/lib/php') in .../test1.php on line 2
此处continue字符串没有打印出来。
看了如果还不明白的话,我做了以下测试,
情况一:
<?php
include("./est.php"); // est.php不存在
echo "<br>continue...";
?>
测试结果:
Warning: include(./est.php): failed to open stream: No such file or directory in .../test1.php on line 2 Warning: include(): Failed opening './est.php' for inclusion (include_path='.:/usr/local/Cellar/php/5.3.10/lib/php') in .../test1.php on line 2
continue...
情况二:
<?php
require("./est.php");
echo "<br>continue...";
?>
测试结果:
Warning: require(./est.php): failed to open stream: No such file or directory in .../test1.php on line 2 Fatal error: require(): Failed opening required './est.php' (include_path='.:/usr/local/Cellar/php/5.3.10/lib/php') in .../test1.php on line 2
此处continue字符串没有打印出来。
推荐阅读
-
php的swoole和rpc区别
-
php和html的区别点详细总结
-
PHP的new static和new self的区别与使用
-
php include和require的区别深入解析
-
PHP中require和include路径问题详解
-
PHP中return 和 exit 、break和contiue 区别与用法
-
require(),include(),require_once()和include_once()的异同
-
php 文件包含 include、include_once、require、require_once
-
php引用和拷贝的区别知识点总结
-
详谈jQuery.load()和Jsp的include的区别