chdir()

chdir to change the directory to a different one. This function returns true on success and false on Failure. We have used getcwd() function to get the current directory location. Here is a sample code.

echo getcwd();
chdir('test_dir');
echo "<br>";
echo getcwd();

Output of above code is here

J:\php_files\t\dir
J:\php_files\t\dir\test_dir

To change from current directory to one step up directory

echo getcwd();
chdir('..');
echo "<br>";
echo getcwd();

As chdir() returns TRUE or FALSE we can use if condition to post message.

echo getcwd();
echo "<br>";
if(@chdir('test_dir2')){
echo getcwd();
}else{
echo " Wrong Directory ";
}



plus2net.com




Post your comments , suggestion , error , requirements etc here .




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2020 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer