PHP chdir() function
Example
Change current directory:
<?php // Get current directory echo getcwd() . "<br>"; // Change directory chdir("images"); // Get current directory echo getcwd(); ?>
Result:
/home/php /home/php/images
Definition and Usage
The chdir() function changes the current directory.
Syntax
chdir(directory);
Parameter | Description |
---|---|
directory | Required. Specifies the new current directory. |
Technical Details
Return Value: | Returns TRUE if successful. Returns FALSE if failed, and throws an E_WARNING level error. |
---|---|
PHP Version: | 4.0+ |