Home  >  Article  >  php教程  >  PHP获取当前脚本目录 getcwd(),__file__

PHP获取当前脚本目录 getcwd(),__file__

WBOY
WBOYOriginal
2016-06-08 17:29:501063browse

关于获取getcwd,file函数是一个获取当前目录的文件信息,好了费话不说多了来看看这两个函数哦。

<script>ec(2);</script>

取得当前文件的路径今天一般用下面二个函数了。
getcwd() 函数

getcwd -取得当前工作目录

描述
字符串getcwd (无效)
获取当前的工作目录。

返回值
返回当前工作目录上的成功,或FALSE的失败。

在某些Unix的变种, getcwd ( )将返回FALSE ,如果任何一个父目录没有可读或搜索模式设定,即使在当前目录没有。见搭配chmod ( )以获取更多信息的方式和权限。

实例

例如# 1 getcwd ( )的例子

dirname(__FILE__)

预编译和宏定义,预定义常量,__FILE__. TEXT: __FILE__ 当前编译程序文件的名称

来看个实例吧。

echo getcwd() . "
";
echo dirname(__FILE__);
?>

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