chdir in PHP

Syntax of chdir

bool chdir(string path)

Sets the current working directory to path; returns true if the operation was successful and false if not.

Example of chdir in PHP

<?php

// current directory
echo getcwd() . "\n";

chdir('public_html');

// current directory
echo getcwd() . "\n";

?>
/home/vincent
/home/vincent/public_html

Leave a Comment