tags:

views:

112

answers:

1

I'm trying to use ftp_connect('ftp.is.co.za') [for example] in PHP 5 or higher (multiple different versions on different machines). I can use the ftp command from the shell in all cases successfully, so it's no a firewall or connectivity issue. I always get NULL as a result, and no errors, if the domain name is valid and serving FTP. I do get errors when there is a problem, i.e. I'm getting NULL as a success message. All versions of PHP involved are compiled with --enable-ftp.

Thanks

As requested, an example:

$ ftp ftp.is.co.za
Connected to ftp.is.co.za (196.4.160.12).
220 ProFTPD 1.3.1 Server (Welcome to Internet Solutions FTP service.) [196.4.160.12]
Name (ftp.is.co.za:myusername): 
Login failed.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> 221 Goodbye.
$ php -a
Interactive shell

php > var_export(ftp_connect("ftp.is.co.za"));
NULL
php > 
$
A: 

ftp_connect() returns a resource type when successful, and the docs for var_export() show that:

Note: Variables of type resource couldn't be exported by this function.

This is probably why var_export() is printing a NULL.

Ben James