php怎样在局部include
1、话不多说,直接上代码
test.php
<?php
header("Content-type: text/html; charset=utf-8");
echo "hello";
echo "<br />";
include("param.php");
echo "<br />";
echo "hello";
echo "<br />";
echo "我有一辆".$car."它是".$color."的";
?>

2、param.php
<?php
$color = "红色";
$car = "小轿车";
echo "我是引入的文件";
?>

3、引用成功执行结果,如下图所示

4、如果在引用之前使用变量会报错
<?php
header("Content-type: text/html; charset=utf-8");
echo "hello";
echo "<br />";
echo "我有一辆".$car."它是".$color."的";
echo "<br />";
include("param.php");
echo "<br />";
echo "hello";
echo "<br />";
echo "我有一辆".$car."它是".$color."的";
?>

5、如果在引用文件中打了断点,那么会导致之后的代码不会执行
param.php
<?php
$color = "红色";
$car = "小轿车";
exit;
echo "我是引入的文件";
?>
test.php
<?php
header("Content-type: text/html; charset=utf-8");
echo "hello";
echo "<br />";
include("param.php");
echo "<br />";
echo "hello";
echo "<br />";
echo "我有一辆".$car."它是".$color."的";
?>

6、执行结果如下图所示。
