Home > Backend Development > PHP Tutorial > 遇到一个文件路径的有关问题,求教

遇到一个文件路径的有关问题,求教

WBOY
Release: 2016-06-13 11:28:01
Original
836 people have browsed it

遇到一个文件路径的问题,求教。
遇到了和该帖楼主一样的问题http://hi.baidu.com/linywh/item/1ae8ac335f0d4ef8e6bb7a73

我的项目文件夹结构是这样的<br /><br />|――images<br />|――include<br />&nbsp |――class<br />&nbsp |――config<br />&nbsp |――function<br />|――index.php<br />在config文件夹中有一个配置文件config.php class文件夹中有一个文件mysql.class.php   我在        config.php中使用require_once("../class/mysql.class.php");<br />而后我 又在index.php中使用require_once ("include/config/config.php");<br />这时它就提示我错误<br /><br />Warning: require_once(../class/mysql.class.php) [function.require-once]: failed to open stream: No such file or directory in E:\www\blog\include\config\config.php on line 13<br /><br />Fatal error: require_once() [function.require]: Failed opening required '../class/mysql.class.php' (include_path='.;C:\php5\pear') in E:\www\blog\include\config\config.php on line 13<br />照常向我这样的初学者、小菜鸟有百度谷歌逛了一下,找了一个方法dirname(__FILE__)用来获得当前文件夹的绝对路径.和dirname()的嵌套使用dirname(dirname(__FILE__))获得上一层目录于是我就改了我config.phpd require_once语句<br />改为require_once(dirname(dirname(__FILE__))."../class/mysql.class.php");<br />接着在index.php中引用config.php就不会出现错误
Copy after login


我按照那个帖子的方法做了,问题解决了,但是我还是不能理解为什么不出错了?在我这,这两个文件路径输出出来分别是这样的:
D:\web\graduatesManagement../class/Database.class.php
D:\web../class/Database.class.php
这两个路径实在是看不懂,求各位帮忙解答一下,谢过。

文件路径
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template