PHP chdir() function

Definition

You can change the working directory using chdir().

Syntax

PHP chdir() function syntax has the following syntax.

chdir(newDir)

Parameter

newDir is the new directory to change.

Return

chdir() returns true on success or false on failure.

Example

Change the working directory using chdir()

<?PHP//  w w w.  j ava  2 s  . c  o  m
     $original_dir = getcwd();
     chdir("/etc");
     $passwd = fopen("passwd", "r");
     fclose($passwd);
     chdir($original_dir);
?>




















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions