Home > Article > Backend Development > Usage of chdir() function in php
chdir() FunctionChange the current directory.
Syntax
chdir(directory);
Parameter directory Required. Specifies the new current directory.
chdir() function example code is as follows:
<?php if (chdir("upload")) { print "Changed current directory successfully"; }//Output:Changed current directory successfully ?>
chdir() function changes the current directory instance code, the code is as follows
<?php // 获取当前目录 echo getcwd() . "<br>"; // 改变目录 chdir("images"); // 获得当前目录 echo getcwd(); ?>
Result:
/home/php /home/php/images
The above is the detailed content of Usage of chdir() function in php. For more information, please follow other related articles on the PHP Chinese website!