本页内容

PHP chdir() 函数

Category:PHP Directory 文件目录参考手册

改变当前的目录:


示例

<?php
// Get current directory

    echo getcwd() . "<br>";

// Change directory

    chdir("images");

// Get current directory

    echo getcwd();

    ?>

结果:


示例

/home/php
/home/php/images

定义和用法

chdir() 函数改变当前的目录。

语法

    chdir(directory);
参数 描述
directory 必需。规定新的当前目录。

技术细节

返回值: 成功则返回 TRUE。失败则返回 FALSE,且抛出 E_WARNING 级别的错误。
PHP 版本: 4.0+

Category:PHP Directory 文件目录参考手册

此页面最后编辑于2022年8月17日 (星期三) 22:14。