简体   繁体   English

定义正确的包含路径

[英]Defining the correct include path

I am facing a include path error. 我面临一个包含路径错误。 In a file config.php I am including include ("./inc/logged_in.php" ); 在文件config.php中,我包括include ("./inc/logged_in.php" ); which (logged_in.php) further includes include ("./include/connect.php" ); 其中(logged_in.php)还包括include ("./include/connect.php" ); but I get a error saying: 但我收到一条错误消息:

failed to open stream: No such file or directory in C:\\xampp\\htdocs\\demo\\fileman\\filemanager\\config\\config.php 无法打开流:C:\\ xampp \\ htdocs \\ demo \\ fileman \\ filemanager \\ config \\ config.php中没有此类文件或目录

Now this error may be because config.php and logged_in.php are in different subfolders and my inclusion path is incorrect. 现在,此错误可能是因为config.php和logging_in.php位于不同的子文件夹中并且我的包含路径不正确。 I tried using include ("../../inc/logged_in.php" ); 我尝试使用include ("../../inc/logged_in.php" ); now no error for logged_in.php but error for connect.php: 现在,logged_in.php没有错误,但connect.php没有错误:

include(./inc/connect.php): failed to open stream: No such file or directory in C:\\xampp\\htdocs\\demo\\inc\\logged_in.php include(./ inc / connect.php):无法打开流:C:\\ xampp \\ htdocs \\ demo \\ inc \\ logged_in.php中没有此类文件或目录

My structure for config.php is: 我的config.php结构为:

// root // 根

// |- demo // |-演示

// | // | |- fileman |-文件人

// | // | | | |- filemanager |-文件管理器

// | // | | | | | |- config |-配置

// | // | | | | | | | |- config.php |-config.php

My structure for connect.php and logged_in.php is: 我的connect.php和logging_in.php结构为:

// root // 根

// |- demo // |-演示

// | // | |- inc |-公司

// | // | | | |- connect.php |-connect.php

// | // | | | |- logged_in.php |-logging_in.php

Check it: 核实:

/demo/fileman/filemanager/config/config.php /demo/fileman/filemanager/config/config.php

include('../../../inc/logged_in.php');

/demo/inc/logged_in.php /demo/inc/logged_in.php

include('connect.php');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM