Couplet Collection Eternal Absolute PHP Get the upper level directory of the code of the absolute path of the file

WBOY
Release: 2016-07-29 08:45:21
Original
1265 people have browsed it

PHP gets the absolute path of the file

Copy the codeThe code is as follows:


echo __FILE__; // Get the absolute address of the current file, result: D:wwwtest.php
echo dirname(__FILE__); //Get the absolute directory where the current file is located, result: D:www
echo dirname(dirname(__FILE__)); //Get the upper directory name of the current file, result: D:
?>


chdir( ) Function
Definition and usage
chdir() function changes the current directory to the specified directory.
If successful, the function returns true, otherwise it returns false.
Syntax
chdir(directory) Parameter Description
directory Required. Specifies the new current directory.
Example

Copy codeThe code is as follows:


//Get the current directory
echo getcwd();
echo "
";
//Change to images directory
chdir("images");
echo "
";
echo getcwd();
?>


Output:
C:testwebmain
C:testwebmainimages

The above introduces the upper-level directory of the code for obtaining the absolute path of the file in the Complete Collection of Couplets Eternal Absolute PHP, including the content of The Complete Collection of Couplets Eternal Absolute. I hope it will be helpful to friends who are interested in PHP tutorials.

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
Latest Issues
javascript - 有什么dom能操作到