Home > Backend Development > PHP Tutorial > PHP获取现阶段文件路径,上层目录路径

PHP获取现阶段文件路径,上层目录路径

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 11:03:06
Original
1039 people have browsed it

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

取的現在檔案、目錄、上層目錄
於 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__));
應用

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