Reputation: 371
I need to check that the $model variable contains an object of type SimpleXMLObject.
$model = convertToSimpleXml($fileName, $filePath);
This is the end of the convertToSimpleXml method where the object is returned using simplexml_load_file
$simpleXml = simplexml_load_file($path);
return $simpleXml;
I've tried checking it as an array or something similar but no luck with that, have looked around for examples but can't find any clear cut answer to the question. Can anyone help?
Upvotes: 0
Views: 38
Reputation: 8845
You can simply check the class of your $simpleXml
:
$simpleXml = simplexml_load_file($path);
if($simpleXml instanceof SimpleXMLElement) {
return $simpleXml;
} else {
return false;
}
Upvotes: 2