我用HTML编写了一个网站,但是我想把头部和导航栏放在一个文件中,这样只需更改一次。于是我将所有页面的扩展名更改为.php并添加了php包含文件。然而现在,对于我已经放进文件夹中以创建无需冗余链接的页面,我遇到了错误。
头部文件:
头部文件:
/test/assets/header.php
正常工作:/test/index.php
包含 <?php include 'assets/header.php'; ?>
出错:/test/company/index.php
包含 <?php include '/test/assets/header.php'; ?>
错误信息:Warning: include(/test/assets/header.php) [function.include]: failed to open stream: No such file or directory
Warning: include() [function.include]: Failed opening '/test/assets/header.php' for inclusion (include_path='.:/usr/local/lib/php:/usr/local/php5/lib/pear')
我遇到了一个问题,无法链接到根目录下文件夹中的头文件。我认为这只是一个简单的问题,只是不知道如何输入URL。如果我尝试包含header.php的完整路径,就会出现“URL文件访问已禁用”的错误。