What is the definition and usage of the PHP chdir () function?
In PHP, the chdir () function is to change the current directory, what it means is to get the current directory, a directory, your current directory is the Www/index directory, when using the ChDir () function, and then return to the current directory, you will find that the current directory is not www/ Index of the directory. This article introduces the PHP chdir () function in detail, hoping to help you.
Syntax for PHP chdir () function
ChDir (directory);
Detailed parameters:
The parameters directory is the new current directory that is specified.
The return value of the PHP chdir () function
php chdir () function returns TRUE if successful. Failure returns false and throws an E_warning level error.
PHP chdir () Function Example
Use the PHP chdir () function to change the current directory with the following code:
<?php//gets the current directory echo GETCWD (). "<br>";//Change Directory Var_dump (chdir ("Images")); echo "<br/>";//Get current directory echo GETCWD (); >
The sample code explains:
In the above example, we first use the GETCWD () function, get to the current directory and return the pathname, then use the chdir () function explained in this article to change the current directory, and then return to the current directory.
The Code browser runs the output:
"Related articles recommended"
How to implement infinite traverse directory in PHP development
How PHP reads all filenames in directories and subdirectories
How PHP modifies the specified file suffix