目录管理函数库_PHP

WBOY
Freigeben: 2016-06-01 12:38:40
Original
983 Leute haben es durchsucht

兼容:(PHP 3, PHP 4, PHP 5)
chdir -- 改变目录
语法:bool chdir ( string directory )
返回值:整数
函数种类: 文件存取

内容说明:
将 PHP 的当前目录改为directory。directory:新的当前目录。返回值如果成功则返回 TRUE,失败则返回 FALSE。


例子讲解:
<font color="#000000"> <font color="#0000BB"></font><font color="#007700"></font><font color="#0000BB">php<br><br></font><font color="#FF8000">// current directory<br><br></font><font color="#007700">echo </font><font color="#0000BB">getcwd</font><font color="#007700">() . </font><font color="#DD0000">"\n\";<br><br>chdir('public_html');<br><br>// current directory<br><br>echo getcwd() . \"\n\";<br><br>?></font> </font>
<font color="#000000"> <font color="#0000BB">输出结果为:<br><br></font><font color="#007700">/</font><font color="#0000BB">home</font><font color="#007700">/</font><font color="#0000BB">vincent <br><br></font><font color="#007700">/</font><font color="#0000BB">home</font><font color="#007700">/</font><font color="#0000BB">vincent</font><font color="#007700">/</font><font color="#0000BB">public_html</font> </font>  

注意:循环语句中会出现“ Warning: chdir(): No such file or directory (errno 2) in ***** on line *”错误。
<font color="#000000"> <font color="#0000BB"></font><font color="#007700"></font><font color="#0000BB">php<br><br></font><font color="#FF8000">// current directory<br><br></font><font color="#007700">echo </font><font color="#0000BB">getcwd</font><font color="#007700">() . </font><font color="#DD0000">"\n\";<br><br>for($i=1; $i<br>    chdir('whoist');<br><br>// current directory<br><br>echo getcwd() . \"\n\";<br><br>}<br><br>?></font> </font>

Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!