-
- echo __FILE__ ; // Get the absolute address of the current file, result: F:wwwtest.php
- echo dirname(__FILE__); // Get the absolute directory where the current file is, result: F: www
- echo dirname(dirname(__FILE__)); //Get the upper directory name of the current file, result: F:
- ?>
Copy code
By the way, here is another function in PHP: chdir() function.
chdir() function
Definition 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. Specifies the new current directory.
Example:
-
-
//Get the current directory - echo getcwd();
- echo "
";
// Change to the images directory
- chdir("images");
- echo "
";
- echo getcwd();
- ?>
-
Copy the code
Output:
C:jbxue.commain
C:jbxue.commainimages
|