PHP获取当前文件路径,上层目录路径

WBOY
Release: 2016-06-23 13:43:08
Original
1226 people have browsed it

取的?在?案、目?、上?目? 

於 test.php ?, 要做取得路?、目?等, 可?下述: 

取得 路? + ?名 (要取得 /var/www/project/test.php) 

    * echo __FILE__; 

取得 ?名 (要取得 test.php) 

    * echo basename(__FILE__); 

取得 不含附?名的?名 (要取得 test) 

    * echo basename(__FILE__, '.php'); 

取得 到此目?前的完整 PATH, 不含?名 (要取得 /var/www/project) 

    * echo dirname(__FILE__); 

取得 到上?目?前的完整 PATH (要取得 /var/www) 

    * echo dirname(dirname(__FILE__)); 


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