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

php ftp_connect()返回bool(true)

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:15:56
Original
1231 people have browsed it

代码如下

<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>
Copy after login
Copy after login

结果如下

<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>
Copy after login
Copy after login

为什么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>
Copy after login
Copy after login

结果如下

<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>
Copy after login
Copy after login

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

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

确实是这个问题
感谢解答

Related labels:
php
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template