I want to be able to detect error with SimpleXMLElement, the errors being:
failed to open HTTP stream
failed to load external entity
Uncaught exception 'Exception' with message 'String could not be parsed as XML'
I have the following code to attempt to detect error.
$xml = new SimpleXMLElement("https://mail.google.com/mail/feed/atom",null,true);
if ($xml === FALSE) {
echo "Wrong username/password combination.";
}
This doesn’t work…. how do I make error detection work?
Exceptions can be caught using a try catch construction:
For the HTTP / Load problems I suggest you use a combination of: