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

Usage of chdir() function in php

怪我咯
Release: 2023-03-13 12:22:01
Original
1818 people have browsed it

chdir() FunctionChange the current directory.

Syntax

chdir(directory);
Copy after login

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
?>
Copy after login

chdir() function changes the current directory instance code, the code is as follows

<?php
// 获取当前目录
echo getcwd() . "<br>";

// 改变目录
chdir("images");

// 获得当前目录
echo getcwd();
?>
Copy after login

Result:

/home/php
/home/php/images
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template