PHP chdir() function
In this chapter you will learn:
- What is PHP chdir() function
- PHP chdir() function syntax
- PHP chdir() function parameter
- PHP chdir() function return value
- Example - Change the working directory using chdir()
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//ja v a 2 s .c o m
$original_dir = getcwd();
chdir("/etc");
$passwd = fopen("passwd", "r");
fclose($passwd);
chdir($original_dir);
?>
Next chapter...
What you will learn in the next chapter:
- What is PHP chgrp() Function
- PHP chgrp() Function syntax
- PHP chgrp() function parameter
- PHP chgrp() Function Return Value
- Example - changes the usergroup of the specified file
Home » PHP Tutorial » PHP File Functions