PHP Get file absolute path
Copy Code code as follows:
<?php
Echo __file__; Get the absolute address of the current file, result: D:\www\test.php
echo dirname (__file__); Gets the absolute directory where the current file is located, as a result: D:\www\
Echo dirname (DirName (__file__)); Gets the top level directory name of the current file, as a result: d:\
?>
ChDir () function
Definitions and usage
The ChDir () function changes the current directory to the specified directory.
If successful, the function returns True, otherwise it returns false.
Grammar
ChDir (directory) parameter description
Directory required. Specify a new current directory.
Example
Copy Code code as follows:
<?php
Get current directory
Echo GETCWD ();
echo "<br/>";
Change to images Directory
ChDir ("Images");
echo "<br/>";
Echo GETCWD ();
?>
Output:
C:\testweb\main
C:\testweb\main\images