Home > Backend Development > PHP Tutorial > PHP gets the current file path and upper directory path_PHP tutorial

PHP gets the current file path and upper directory path_PHP tutorial

WBOY
Release: 2016-07-13 17:52:32
Original
1733 people have browsed it

Get the current file name, current directory, and upper directory

File name test.php
Path + file name (to get /var/www/test/test.php)
echo __FILE__;
File name (to get test.php)
echo basename(__FILE__);
File name without extension (to get test)
echo basename(__FILE__, '.php');
Complete PATH to this directory, excluding file names (to obtain /var/www/test)
echo dirname(__FILE__);
The upper directory PATH of the current file (to obtain /var/www)
echo dirname(dirname(__FILE__));


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478102.htmlTechArticleGet the current file name, current directory, upper directory file name test.php path + file name (to get /var /www/test/test.php) echo __FILE__; File name (to get test.php) echo basename...
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