简体   繁体   English

相对路径一级无法在PHP中使用

[英]Relative path one level up not working in PHP

Currently I have the following structure 目前我有以下结构

httpdocs - system - templates httpdocs-系统-模板

Inside templates I have the following line 在模板内部,我有以下内容

require_once(__DIR__.'/../system/config.php');

I get the following error 我收到以下错误

Warning: require_once(/var/www/vhosts/domain/httpdocs/templates/../system/config.php): failed to open stream: No such file or directory in /var/www/vhosts/domain/httpdocs/templates/header.php on line 8

Fatal error: require_once(): Failed opening required '/var/www/vhosts/domain/httpdocs/templates/../system/config.php' (include_path='.:') in /var/www/vhosts/domain/httpdocs/templates/header.php on line 8

As you can see in the path it just adds the two dots (../) as if it is part of the path, while I meant it to go up one level. 正如您在路径中看到的那样,它只是将两个点(../)加在一起,就好像它是路径的一部分一样,而我的意思是使它上升一个级别。 Is there a PHP setting required to support relative paths or something? 是否需要支持相对路径之类的PHP设置?

I tried all possible variants of the path in- and excluding the DIR magic constant to no avail. 我尝试了所有可能的路径变体,但没有排除DIR魔术常数。 And yes, config.php is present in system. 是的,config.php存在于系统中。

Deeply ashamed. 深感as愧。 After I moved the page to another server, I had changed the name of the system folder. 将页面移到另一台服务器后,我已经更改了系统文件夹的名称。

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

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