note 100526 modified in function.simplexml-load-file by danbrown
| From: | danbrown@php.net | Date: | Thu, 21 Oct 2010 13:24:52 +0000 |
| Subject: | note 100526 modified in function.simplexml-load-file by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-173345@lists.php.net to get a copy of this message | ||
if you want to check when this function fails,make sure to compare the return value with ===
instead of == :
<?php
$url = 'http://www.example.com';
$xml = simpleXML_load_file($url,"SimpleXMLElement",LIBXML_NOCDATA);
if($xml === FALSE)
{
//deal with error
}
else { //do stuff }
?>
Otherwise you may end up with FALSE all the time even if the document is ok. Hope this helps someone
;)
--was--
if you want to check when this function fails,make sure to compare the return value with ===
instead of == :
$url = 'http://www.example.com';
$xml = simpleXML_load_file($url,"SimpleXMLElement",LIBXML_NOCDATA);
if($xml === FALSE)
{
//deal with error
}
else { //do stuff }
Otherwise you may end up with FALSE all the time even if the document is ok. Hope this helps someone
;)
http://php.net/manual/en/function.simplexml-load-file.php