我们可以在php页面中使用include(page.php)两次.任何错误的可能性
例如:
include(page.php);
-------
--------
--------
--------
include(page.php);
Run Code Online (Sandbox Code Playgroud)
但它可能会对您的代码产生一些负面影响.
考虑一下......
test1.php
<?php
$var=1;
Run Code Online (Sandbox Code Playgroud)
test2.php
<?php
include('test1.php');
echo $var; // "prints" 1
$var = 30;
include('test1.php');
echo $var; // "prints" 1 again.
Run Code Online (Sandbox Code Playgroud)
要克服这种情况,你应该使用include_once()构造.