edzillion Posted March 6, 2008 Share Posted March 6, 2008 I am making a wordpress widget and I want it to deal with a site being down. The code: $xml = simplexml_load_file('scripts/pricefeed.php'); if($xml) { //display widget etc. Pricefeed checks if the URL exists and returns false if it does not: <?php $fileUrl = "http://dgcsc.org/goldprices2.xml"; $AgetHeaders = @get_headers($fileUrl); if (preg_match("|200|", $AgetHeaders[0])) { // file exists readfile($fileUrl); } else { // file doesn't exist return false; } ?> it works fine if the URL is there but if it isnt I get the error 'parser error : Document is empty' on the simple_xml_load line. Do I need a try catch statement or something? Not v. experienced at that.... Link to comment https://forums.phpfreaks.com/topic/94693-error-handling-simplexml_load_file/ Share on other sites More sharing options...
edzillion Posted March 7, 2008 Author Share Posted March 7, 2008 anyone? Link to comment https://forums.phpfreaks.com/topic/94693-error-handling-simplexml_load_file/#findComment-485954 Share on other sites More sharing options...
edzillion Posted March 7, 2008 Author Share Posted March 7, 2008 at all? Link to comment https://forums.phpfreaks.com/topic/94693-error-handling-simplexml_load_file/#findComment-486208 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.