Test FTP connection with PHP

后端 未结 6 939
独厮守ぢ
独厮守ぢ 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:21

    Simply do a check if ftp_nlist() is an array.

    Like:

    echo is_array(ftp_nlist($con, ".")) ? 'Connected!' : 'not Connected! :(';

    References:

    • http://php.net/manual/en/function.is-array.php
    • http://php.net/manual/en/function.ftp-nlist.php

提交回复
热议问题