Heim  >  Fragen und Antworten  >  Hauptteil

php ftp_connect()返回bool(true)

代码如下
<?php

$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);

结果如下

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

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

ringa_leeringa_lee2727 Tage vor614

Antworte allen(2)Ich werde antworten

  • PHP中文网

    PHP中文网2017-04-10 17:00:14

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

    Antwort
    0
  • PHP中文网

    PHP中文网2017-04-10 17:00:14

    确实是这个问题
    感谢解答

    Antwort
    0
  • StornierenAntwort