我正在尝试使用PHP中的SSL连接设置FTP。我尝试使用ftp_ssl_connect()和ssh2_sftp()但我收到此错误:
致命错误:调用未定义的函数ftp_ssl_connect()
致命错误:调用未定义的函数ssh2_connect()
我确实在PHP扩展中启用了openssl扩展。
数组([0] => php 1 =>文件2 => glob [3] =>数据[4] => http [5] => ftp [6] => zip [7] => compress.zlib [8] => compress.bzip2 [9] => https [10] => ftps [11] => phar)
以下是来自here的简单代码:
$conn_id = ftp_ssl_connect($ftp_server);
$ftp_user_name = "username";
$ftp_user_pass = "password";
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
ftp_pasv($conn_id, true);
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user $ftp_user_name";
exit;
} else {
echo "Connected to $ftp_server, for user $ftp_user_name";
}
来自here的SSH2:
$connection = ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');
$sftp = ssh2_sftp($connection);
我在Windows 10和Mac OS X中使用XAMPP,PHP 5.6.31。两个操作系统都出现了相同的错误。这里的任何人都想帮我解决这个问题吗?