I've been following the example for PHP error handling using simplexml_load_file as show in this example:

http://www.ibm.com/developerworks/library/x-simplexml.html

To test my PHP code, I put in a bogus URL, which failed and the PHP script caught it allowing me to control it in the program.

But when the actual URL's server is down, PHP gives errors about it and aborts the script. The error handling isn't caught by this method. I had a PHP script running for months without a problem and I guess it had just been lucky until recently not to encounter any network problems.

The CRON was nice enough to e-mail root errors from the script that it complained about:

PHP Warning: simplexml_load_file(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in blahblah.php on line 17 PHP Warning: simplexml_load_file(http://example.com): failed to open stream: Connection timed out in blahblah.php on line 17 PHP Warning: simplexml_load_file(): I/O warning : failed to load external entity "http://example.com"; in blahblah.php on line 17

My impression is that the PHP program encountered these errors and simply aborted and didn't give my code a chance to execute.

Is the technique in this article wrong? What can be done to make this more robust cause networks won't be up and running all the time. Thanks!

David Roth


_______________________________________________
New York PHP Users Group Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

http://www.nyphp.org/Show-Participation

Reply via email to