1、当涉及<script src=""></script>

                        <link href="">

                         <a href=""></a>

                        <img src="" alt="">

等这些需要链接或者载入资源文件时,一定要使用绝对路径,避免如果根目录发生变化还可以使用。

2、因为这个 sidebar.php 是被 index.php 载入执行,与上文不一样。所以 这里的相对路径 是相对于 index.php
// 如果希望根治这个问题,可以采用物理路径解决
require_once '../functions.php';

// require_once dirname(__FILE__).'/../../functions.php';

php中什么时候写相对路径,什么时候写绝对路径

php中什么时候写相对路径,什么时候写绝对路径

相关文章: