我是php的新手,我在使用我的代码运行另一个脚本时遇到问题。我想要运行的脚本位于相同的文件夹中,但所包含的脚本位于以下四个级别的文件夹中。请帮助我。我的目录树如下所示。
websystem\-
|-Administrator\
|-vehicle_details\vehicles\aston_martin\index.php
|-explore-vehicle.php
require(".../websystems/explore-vehicle.php");
我已经编写了上面的代码,但它似乎没有运行脚本。假设我的主目录是aston_martin,我想在下面的四个级别运行脚本explore-vehicle.php
。我的目录是\websystems\vehicles_details\vehicles\aston_martin\index.php
,我想在\websystems\explore-vehicle.php
中运行脚本。
答案 0 :(得分:3)
你可能想要一些东西(假设你在index.php
的{{1}}页面上):
aston_martin
如果您需要更改其他目录,而不仅仅是您最终使用的目录,您可以这样做,例如:
require("../../../explore-vehicle.php");