目录管理函数库
来源:网络 作者:佚名 点击:
次时间:2017-09-20 03:24
[摘要] 兼容:(PHP 3, PHP 4, PHP 5) chdir -- 改变目录 语法:bool chdir ( string directory ) 返回值:整数 函数种类: 文件存取 内容说明: 将 PHP 的当前目录改为directory。directory:新的当前目录。返回值如果成功则返
兼容:(PHP 3, PHP 4, PHP 5)
chdir -- 改变目录
语法:bool chdir ( string directory )
返回值:整数
函数种类: 文件存取
内容说明:
将 PHP 的当前目录改为directory。directory:新的当前目录。返回值如果成功则返回 TRUE,失败则返回 FALSE。
例子讲解:
<?php
// current directory
echo getcwd() . "\n\";
chdir('public_html');
// current directory
echo getcwd() . \"\n\";
?>
输出结果为:
/home/vincent
/home/vincent/public_html
注意:循环语句中会出现“
Warning: chdir(): No such file or directory (errno 2) in ***** on line
*”错误。
<?php
// current directory
echo getcwd() . "\n\";
for($i=1; $i<=2; $i++){
chdir('whoist');
// current directory
echo getcwd() . \"\n\";
}
?>
|
------分隔线----------------------------