PHP 教程 PHP chdir() 函数

tobyn · 2022-03-07 11:05:50 · 热度: 4

实例

改变当前的目录:

<?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+

查看更多 PHP Directory 函数

猜你喜欢:
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册