note 85114 modified in simplexml.examples by felipe
| From: | felipe@php.net | Date: | Fri, 15 Aug 2008 23:17:00 +0000 |
| Subject: | note 85114 modified in simplexml.examples by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-143548@lists.php.net to get a copy of this message | ||
To take care of proper error checking, one must use try-catch blocks:
<?php
try {
$sxe = new SimpleXMLElement($xmlstring);
} catch (Exception $e) {
echo "bad xml";
}
?>
To get rid of warnings, use @ in front of new:
<?php
try {
$sxe = @new SimpleXMLElement($xmlstring);
} catch (Exception $e) {
echo "bad xml";
}
?>
--was--
To take care of proper error checking, one must use try-catch blocks:
try {
$sxe = new SimpleXMLElement($xmlstring);
} catch (Exception $e) {
echo "bad xml";
}
To get rid of warnings, use @ in front of new:
try {
$sxe = @new SimpleXMLElement($xmlstring);
} catch (Exception $e) {
echo "bad xml";
}
http://php.net/manual/en/simplexml.examples.php