w3resource
PHP Tutorial

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



New Content: Composer: Dependency manager for PHP, R Programming