我有一个看起来像这样的文件结构(遗漏了不重要的文件):
Testserver
-file.php
PHP
-functions.php
Administration
-index.php
现在当我尝试调用require_once('../ PHP / functions.php');在“index.php”里面它不起作用,我不明白为什么。谁知道问题可能是什么?
这很好用:
require_once('../file.php');
答案 0 :(得分:1)
首先感谢所有答案,我现在发现了这个错误:
在functions.php中我需要另一个文件,当我从index.php中调用它时,该文件的路径不正确
所以我不得不改变functions.php里面的路径而不是index.php里面的路径
还要感谢大家提出的其他建议:)
答案 1 :(得分:0)
以下内容应该可以正常运行:
require_once('../PHP/functions.php');
答案 2 :(得分:0)
你有一个像这样的文件夹结构:
Testserver
-file.php
PHP
-functions.php
Administration
-index.php
然后,您在index.php
内部尝试访问位于目录functions.php
内的文件PHP
。然后,您需要从index.php
文件的当前目录(即Administration
目录)上升一个目录[意味着您从Testserver
到达Administration
文件夹}文件夹],然后深入查看PHP
目录。在代码中,这意味着:
<?php
require_once __DIR__ . "/../PHP/functions.php";
希望这能为你做到。
干杯&amp;祝你好运....
答案 3 :(得分:0)
检查您对该文件夹的权限,然后尝试:
require_once('../PHP/functions.php')