Home  >  Article  >  Backend Development  >  php基础学习- _FILE_变量获取资料所在目录

php基础学习- _FILE_变量获取资料所在目录

WBOY
WBOYOriginal
2016-06-13 13:11:44714browse

php基础学习-- __FILE__变量获取文件所在目录

?

dirname(dirname(__FILE__));得到的是文件上一层目录名

如:E:\PHP\wamp\www\testSource

str_replace('\\','/',dirname(__FILE__))?;得到的是文件上一层目录名并进行斜杠替换

E:/PHP/wamp/www/testSource

dirname(__FILE__);得到的是文件所在层目录名

str_replace('\\','/',substr(dirname(__FILE__),0,-3));得到的是文件所在层目录名并进行斜杠替换

如:E:/PHP/wamp/www/testSource/src

?

>>资料引自:玛丽时尚:http://www.10086money.com

?(转载请注明出处:[url=http://www.live588.org]*[/url])

?

Statement:
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