【发布时间】:2018-09-08 05:57:18
【问题描述】:
我正在从头开始在后台工作,这里有一些文件夹示例
管理 > 包含 > global_variable.php
管理 > 滑块 > variable.php
管理 > 滑块 > 上传功能 > index.php
在 index.php 我有
<?php include('../variable.php'); ?>
在 variable.php 我有
<?php include('../include/global_variable.php');?>
但是 index.php 没有读取 global_variable.php
它给了我以下错误
"Warning: include(../include/global_variable.php): failed to open stream: No such file or directory in [irrelevant]\Admin\sliders\variable.php on line <i>1</i>"
不,这不是正斜杠和反斜杠的问题,因为它在不同的架构上工作(我正在链接 ../variable.php 和 ../../include/global_variable.php在我的 index.php 上)
从逻辑上讲,这应该有效,但事实并非如此。 我的假设是它正在从 index.php 的目录中读取“../include/global_variable.php”(它应该从 variable.php 中读取)
在保持相同文件结构的同时有什么解决方法吗?
谢谢
【问题讨论】:
-
我遇到了同样的问题。尝试检查此link。另外,也许您可以检查如何使用
__DIR__(对部署有用) -
谢谢@LilianBarriud 这很有用!
标签: php