Root
/index.php ----//The homepage, including head.php works fine
/s/affiliate.php ----//A sub page, will not load the head.php
/structure/head.php
所以上面是如何阐述的。我试图在我网站的页面中包含头部。我有几百页。它在index.php上使用
工作正常<?php include "structure/head.php"; ?>
然而,在任何子页面上,它都不会加载。我猜它是搜索目录的方式,但我也试图让它从root搜索,它仍然无法工作,任何想法?
<?php include( $_SERVER['DOCUMENT_ROOT'] . '/structure/head.php' ); ?>
答案 0 :(得分:1)
使用相对路径:
include("../structure/head.php");
答案 1 :(得分:0)
尝试使用
<!-- here's a table -->
<form action="" onsubmit="return checkData();" class="hiddenForm" enctype="multipart/form-data" id="myform">
<!-- skipping the first row to save space -->
<tr>
<td colspan="2"><i class="mand">*</i><i style="font-size: 10pt"> = required</i></td>
<td><input type="submit" name="submit" value="Send"></td>
<td colspan="2" id="conf"></td> <!-- In this <td> should come the "Sent!"
message -->
</tr>
</form>
</table>
而不是DOCUMENT_ROOT,
修改强>
这应该有效
$_SERVER['HTTP_HOST']
答案 2 :(得分:0)
使用include(&#34; ../ path / to / head.php&#34;); 这应该有效,因为它可以将您的代码定向到您存储head.php的子目录