Home  >  Article  >  Backend Development  >  PHP获取当前文件路径,上层目录路径

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

WBOY
WBOYOriginal
2016-06-23 13:43:081223browse

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

於 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__)); 


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