函数名:ftp_pwd()
适用版本:PHP 4, PHP 5, PHP 7
用法:ftp_pwd() 函数用于获取当前工作目录的路径。
语法:string ftp_pwd ( resource $ftp_stream )
参数:
返回值:返回当前工作目录的路径,如果出错则返回 false。
示例:
// 建立 FTP 连接
$ftp_server = 'ftp.example.com';
$ftp_user = 'username';
$ftp_pass = 'password';
$conn = ftp_connect($ftp_server);
ftp_login($conn, $ftp_user, $ftp_pass);
// 获取当前工作目录的路径
$current_dir = ftp_pwd($conn);
if ($current_dir !== false) {
echo "当前工作目录的路径为:" . $current_dir;
} else {
echo "获取当前工作目录失败";
}
// 关闭 FTP 连接
ftp_close($conn);
注意事项: