Jump to: navigation, search

Php chdir

From w3cyberlearnings

Contents

PHP function chdir

This function changes a current directory to another directory.

Syntax chdir

directory to change to

chdir(directory);

Example 1

<?php
// current directory
echo getcwd();
echo "<br />";
//Change to the content directory
chdir("content");
echo "<br />";
echo getcwd();
?>

Output

/home/abc/
/home/abc/content

Example 2: Microsoft Windows

<?php 
 echo chdir('C:\\');  
?>

Example 3: Linux

<?php 
   chdir("/var/www");
   echo getcwd();
?>

--chdir-- chroot-- closedir-- dir-- getcwd-- opendir-- readdir-- rewinddir-- scandir--

Navigation
Web
SQL
MISC
References