Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 php 中,我如何从不在主目录中的页面中选择头文件?
include('/path/to/the/header/file.php');
您可以使用绝对路径和相对路径。如果您根本不指定路径,PHP 将搜索其 include_path 设置并按顺序检查每个目录。
require_once('../header.php');
将包含父目录中的 header.php 文件。对 require 函数使用相对或绝对路径。