w3resource

PHP: chdir() function

Description

The chdir() function is used to change the current working directory to a specified dir.

Version:

(PHP 4 and above)

Syntax:

chdir(dir_name)

Parameter:

Name Description Required /
Optional
Type
dir_name The new current directory. Required String

Return value:

TRUE on success or FALSE on failure.

Value Type: Boolean.

Example:

<?php
echo getcwd() .'<br>';
echo "Change to the 'test' directory".'<br>';
chdir('test');
echo getcwd() ;
?>

See also

PHP Function Reference

Previous: time
Next: chroot



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/php/function-reference/chdir.php