我想在我的网页上使用php。除了include语句之外,index.php页面中的php可以正常工作。echo语句正常工作。我尝试了各种使用include语句的方法,你可以在这里看到。有三种不同的方法。我也试过不加括号地使用它们。我在Index.php中引用的三个文件都位于Index.php所在的同一目录中。我试过了,什么都不管用,可我还是弄不明白。
index . php:
<?php
echo 'test';
session_start();
echo 'test';
include($_SERVER['DOCUMENT_ROOT']."header.php");
include("connect.php");
$database = 'NJVCtestDB';
$server = '10.3.171.108';
echo getcwd();
?>
<p>Index.php</p>
<?php
echo 'test';
require("footer.php");?>
header。php:
<!DOCTYPE html>
<head>
<?php
session_start()
echo 'test';
?>
<title></title>
</head>
<body>
footer。php:
<p>footer.php</p>
</body>
</html>
我想你错过了一个渣,
include($_SERVER['DOCUMENT_ROOT']."header.php");
应:include($_SERVER['DOCUMENT_ROOT']."/header.php");