PHP chdir() Function
The PHP chdir() function changes the current directory to the specified directory.
Syntax
chdir(directory)
Parameters
directory |
Required. Specify the new current directory. |
Return Value
Returns true on success or false on failure.
Exceptions
Throws an error of level E_WARNING on failure.
Example:
The example below shows the usage of chdir() function.
<?php //getting current directory echo getcwd()."\n"; //changing the current directory chdir('temp'); //getting current directory echo getcwd()."\n"; ?>
The output of the above code will be:
/home/html /home/html/temp
❮ PHP Directory Reference