array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.ftp-site.php', 1 => 'ftp_site', ), 'up' => array ( 0 => 'ref.ftp.php', 1 => 'FTP 函数', ), 'prev' => array ( 0 => 'function.ftp-set-option.php', 1 => 'ftp_set_option', ), 'next' => array ( 0 => 'function.ftp-size.php', 1 => 'ftp_size', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/ftp/functions/ftp-site.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
ftp_site — 向服务器发送 SITE 命令
ftp_site() 函数向 FTP 服务器发送指定的命令。
SITE
命令是非标准化的,不同的服务器不尽相同。主要用于处理文件权限以及组成员等事情。
版本 | 说明 |
---|---|
8.1.0 |
现在 ftp 参数接受 FTP\Connection
实例,之前接受 resource。
|
示例 #1 向 FTP 服务器发送 SITE 命令
<?php
// 连接 FTP 服务器
$ftp = ftp_connect('ftp.example.com');
if (!$ftp) die('无法连接到 ftp.example.com');
// 使用用户 user 和密码 pass 登录服务器
if (!ftp_login($ftp, 'user', 'pass')) die('登录失败到 ftp.example.com');
// Issue: "SITE CHMOD 0600 /home/user/privatefile" command to ftp server
if (ftp_site($ftp, 'CHMOD 0600 /home/user/privatefile')) {
echo "命令执行成功。\n";
} else {
die('命令执行失败。');
}
?>