PHP Directory

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

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 :

  1. echo getcwd() .'
    ';  

  2. echo "Change to the 'test' directory".'
    ';  

  3. chdir('test');  

  4. echo getcwd() ;  

  5. ?>