How do I error handle the FTP functions in PHP
When connecting to mysql, I have functions to get the relevant error message and error code, I see nothing of the sort in the list of ftp functions of PHP.
Is there a best practice to handle errors in FTP?EDIT+CLARIFICATION: I think the best error messages are the开发者_开发技巧 system error messages + my own, is there a way to catch the system error messages?
Try error_get_last()
for PHP >= 5.2 or $php_errmsg
for older versions as detailed at the linked pages
Looks like most of the ftp functions just return a true or false status. Some trigger a warning.
So the option you probably have is to check return status and have a meaningful error log for yourself.
You can check the values returned by the functions. Usually it will return something like true (success) and false (fail). For instance, take ftp_fget
. php.net says:
Returns TRUE on success or FALSE on failure.
精彩评论