Home  >  Article  >  Backend Development  >  php ftp_connect()返回bool(true)

php ftp_connect()返回bool(true)

WBOY
WBOYOriginal
2016-06-06 20:15:561166browse

代码如下

<code>$ftpServer = "192.168.1.118";
$ftpUser = "hqzn-ftp";
$ftpPwd = "123456";

$conn = ftp_connect($ftpServer) || die(printf("Couldn't connect to $s", $ftpServer));
var_dump($conn);
$login_result = ftp_login($conn, $ftpUser, $ftpPwd);
</code>

结果如下

<code>bool(true) 
Warning: ftp_login() expects parameter 1 to be resource, boolean given in C:\Users\hqzn\phpStudy\WWW\EasyDarwin\html\ftp.php on line 8
</code>

为什么ftp_connetc返回了一个bool(true)?
导致ftp_login无法连接上ftp
使用ftp工具是可以正常连接的

回复内容:

代码如下

<code>$ftpServer = "192.168.1.118";
$ftpUser = "hqzn-ftp";
$ftpPwd = "123456";

$conn = ftp_connect($ftpServer) || die(printf("Couldn't connect to $s", $ftpServer));
var_dump($conn);
$login_result = ftp_login($conn, $ftpUser, $ftpPwd);
</code>

结果如下

<code>bool(true) 
Warning: ftp_login() expects parameter 1 to be resource, boolean given in C:\Users\hqzn\phpStudy\WWW\EasyDarwin\html\ftp.php on line 8
</code>

为什么ftp_connetc返回了一个bool(true)?
导致ftp_login无法连接上ftp
使用ftp工具是可以正常连接的

ftp_connect($ftpServer) || die(printf("Couldn't connect to $s", $ftpServer)); 中的 || 换成 or 就好了

确实是这个问题
感谢解答

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn