如何使用 FTP_Implicit_SSL class 连接到隐式 SSL/TSL?
How do I use FTP_Implicit_SSL class to connect to Implicit SSL/TSL?
我需要使用隐式 SSL/TLS
连接到 FTP 服务器
快速 Google 我找到了 this chaps wrapper class
但是没有演示如何使用呢?我无法从中看出如何或在何处指定用户名、密码等...
我相信这很容易,但我就是不知道如何设置它们。如果我 运行 以下代码,我会立即收到错误消息:
<?php
include "../objects/shared/ftp-implicit-ssl-tls.php";
$FTP_Implicit_SSL = new FTP_Implicit_SSL();
?>
错误:
Warning: Missing argument 1 for FTP_Implicit_SSL::__construct(), called in C:\wamp\www_dev\ftp.php on line 4 and defined in C:\wamp\www\objects\shared\ftp-implicit-ssl-tls.php on line 35
我是否在 class 本身中设置凭据?当然不是!
我认为您没有仔细阅读 class。当您创建一个新的 class 时,您需要寻找 __construct() method,因为这就是您调用 new class()
时调用的内容
/**
* Connect to FTP server over Implicit SSL/TLS
*
*
* @access public
* @since 1.0
* @param string $username
* @param string $password
* @param string $server
* @param int $port
* @param string $initial_path
* @param bool $passive_mode
* @throws Exception - blank username / password / port
* @return \FTP_Implicit_SSL
*/
public function __construct( $username, $password, $server, $port = 990, $initial_path = '', $passive_mode = false ) {
注释中的第一部分称为 docblock,它告诉您使用这些参数实例化 class 所需知道的一切。所以它看起来像这样
$FTP_Implicit_SSL = new FTP_Implicit_SSL($username, $password, 'your.server.com');
我需要使用隐式 SSL/TLS
连接到 FTP 服务器快速 Google 我找到了 this chaps wrapper class
但是没有演示如何使用呢?我无法从中看出如何或在何处指定用户名、密码等...
我相信这很容易,但我就是不知道如何设置它们。如果我 运行 以下代码,我会立即收到错误消息:
<?php
include "../objects/shared/ftp-implicit-ssl-tls.php";
$FTP_Implicit_SSL = new FTP_Implicit_SSL();
?>
错误:
Warning: Missing argument 1 for FTP_Implicit_SSL::__construct(), called in C:\wamp\www_dev\ftp.php on line 4 and defined in C:\wamp\www\objects\shared\ftp-implicit-ssl-tls.php on line 35
我是否在 class 本身中设置凭据?当然不是!
我认为您没有仔细阅读 class。当您创建一个新的 class 时,您需要寻找 __construct() method,因为这就是您调用 new class()
/**
* Connect to FTP server over Implicit SSL/TLS
*
*
* @access public
* @since 1.0
* @param string $username
* @param string $password
* @param string $server
* @param int $port
* @param string $initial_path
* @param bool $passive_mode
* @throws Exception - blank username / password / port
* @return \FTP_Implicit_SSL
*/
public function __construct( $username, $password, $server, $port = 990, $initial_path = '', $passive_mode = false ) {
注释中的第一部分称为 docblock,它告诉您使用这些参数实例化 class 所需知道的一切。所以它看起来像这样
$FTP_Implicit_SSL = new FTP_Implicit_SSL($username, $password, 'your.server.com');