PHP chdir () function
Examples
Change the current directory:
<?php
// Get current directory
echo getcwd() . "<br>";
// Change directory
chdir("images");
// Get current directory
echo getcwd();
?>
// Get current directory
echo getcwd() . "<br>";
// Change directory
chdir("images");
// Get current directory
echo getcwd();
?>
result:
/home/php
/home/php/images
/home/php/images
Definition and Usage
chdir () function to change the current directory.
grammar
chdir( directory );
参数 | 描述 |
---|---|
directory | 必需。规定新的当前目录。 |
technical details
return value: | Success, returns TRUE. It failed to return FALSE, and throws E_WARNING level error. |
---|---|
PHP version: | 4.0+ |
PHP Directory Reference