Home > Backend Development > PHP Tutorial > php获取路径函数总结

php获取路径函数总结

WBOY
Release: 2016-06-20 12:31:14
Original
1224 people have browsed it

![输入图片说明](https://static.oschina.net/uploads/img/201604/19160021_NkM5.png "在这里输入图片标题")```__FILE__ 和$_SERVER['SCRIPT_FILENAME']都是返回 PHP 文件的完整路径(绝对路径)与文件名,区别在于$_SERVER['SCRIPT_FILENAME'] 反映的是当前执行程序的绝对路径及文件名;__FILE__ 反映的是原始文件(被包含文件)的绝对路径及文件名```例如我把两个函数写在test/haha.php文件下,在test.php文件中导入haha.php,游览器访问test.php输出结果如下:![输入图片说明](https://static.oschina.net/uploads/img/201604/19160424_Psfo.png "在这里输入图片标题")![输入图片说明](https://static.oschina.net/uploads/img/201604/19160328_BOVe.png "在这里输入图片标题")![输入图片说明](https://static.oschina.net/uploads/img/201604/19163031_bxIC.png "在这里输入图片标题")![输入图片说明](https://static.oschina.net/uploads/img/201604/19163303_qsk0.png "在这里输入图片标题")![输入图片说明](https://static.oschina.net/uploads/img/201604/19163457_e7ZR.png "在这里输入图片标题")![输入图片说明](https://static.oschina.net/uploads/img/201604/19163850_4qdK.png "在这里输入图片标题")
Copy after login

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