Php 包含文件的不同路径
我的项目结构如下(观看图片)。我需要在每个文件中包含menu.php,但index.php需要不同的路径:Php 包含文件的不同路径,php,Php,我的项目结构如下(观看图片)。我需要在每个文件中包含menu.php,但index.php需要不同的路径: 我怎样才能解决这个问题?我不使用框架。根据相关文件设置包含路径 可以使用添加相对路径 例如,在index.php set_include_path(implode(PATH_SEPARATOR, [ __DIR__ . '/../contenido', get_include_path() ])); 在您的远景/productos脚本中 set_include_path
我怎样才能解决这个问题?我不使用框架。根据相关文件设置包含路径 可以使用添加相对路径 例如,在
index.php
set_include_path(implode(PATH_SEPARATOR, [
__DIR__ . '/../contenido',
get_include_path()
]));
在您的远景/productos
脚本中
set_include_path(implode(PATH_SEPARATOR, [
__DIR__ . '/../../contenido',
get_include_path()
]));
然后,不管你在哪里,你可以简单地添加
include 'menu.html';
include 'menu.html';