Home  >  Article  >  Backend Development  >  Usage of chdir() function in php

Usage of chdir() function in php

怪我咯
怪我咯Original
2017-07-10 15:19:211809browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn