PHP - Function chdir()


Advertisements


Syntax

bool chdir ( string $directory )

Definition and Usage

It changes PHP's current directory to the passed directory.

Parameters

Sr.No Parameter & Description
1

directory(Required)

The new current directory

Return Value

It returns TRUE on success or FALSE on failure.

Example

Following is the usage of this function −

<?php
   echo getcwd() . "\n";
   
   chdir('html');
   
   echo getcwd() . "\n";
?> 

This will produce the following result −

/home/tutorialspoint
/home/tutorialspoint/html

php_function_reference.htm

Advertisements