Example
Change the 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: | TRUE on success. FALSE on failure. Throws an error of level E_WARNING on failure |
---|---|
PHP Version: | 4.0+ |
< PHP Directory Reference