Really quick try/catch question
| From: | Brian Dunning | Date: | Tue, 18 Aug 2009 19:29:12 +0000 |
| Subject: | Really quick try/catch question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-296941@lists.php.net to get a copy of this message | ||
I have a "new SimpleXMLElement()" that is occasionally throwing:
'Exception: String could not be parsed as XML'
Will this catch it when it happens, or am I missing something?
function domyfunction() {
// This does some stuff to exit the script gracefully
}
try {
$xmlobject = new SimpleXMLElement($xml);
} catch($e) {
domyfunction($e);
}