Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP-包含在子目录中不工作_Php_Directory_Include_Include Path_Subdirectory - Fatal编程技术网

PHP-包含在子目录中不工作

PHP-包含在子目录中不工作,php,directory,include,include-path,subdirectory,Php,Directory,Include,Include Path,Subdirectory,这就是我所拥有的 site.com/user/filehere.php 我要去 site.com/user/messages/index.php php是 <?php include_once("../filehere.php"); ?> 即使我直接访问包含的文件时一切正常,这些包含也不会在/messages目录中重新确认将\uuuuuuu目录添加到文件路径以表示当前的php目录。有关更多信息,请参阅此项。subdir的相同问题显示页面正常,但页面中的包含内容未显示今天我也

这就是我所拥有的

site.com/user/filehere.php
我要去

site.com/user/messages/index.php 
php是

<?php 
include_once("../filehere.php");
?>

即使我直接访问包含的文件时一切正常,这些包含也不会在/messages目录中重新确认

\uuuuuuu目录添加到文件路径以表示当前的php目录。有关更多信息,请参阅此项。

subdir的相同问题显示页面正常,但页面中的包含内容未显示今天我也遇到了此问题,我通过指定绝对路径来解决此问题。例如,我使用laravel,我使用
app_path()/services/aaa.php'
我是用纯php编写的,因此我必须更改站点中的所有内容,可能您可以为您的php文件编写一个简单的自动加载程序,这将节省大量工作。可能还有其他的包含方式。等待专家的回答。我想我会用
include\u once($\u SERVER['DOCUMENT\u ROOT']./site/user/file.php')一个接一个地进行更改我将看到我将实现什么
<?php  

include_once("../menu.php); 

?>