Test FTP connection with PHP

后端 未结 6 942
独厮守ぢ
独厮守ぢ 2021-02-05 08:55

I am using the PHP script below to test FTP connections. Currently it is printing an array of the files, if it successfully connects.

How can I get it to also display

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-05 09:24

    Note that you're already dieing when you fail to connect, so you can assume that you are connected. However, you can also check the status of the connection using:

    echo $con !== FALSE ? 'Connected' : "Couldn't connect";
    

    ftp_connect: Returns a FTP stream on success or FALSE on error.

提交回复
热议问题