which is better expression to make string into xml object[php]?
$xml = new SimpleXMLElement($xml_string);
vs
$xml = simplexml_load_string($xml_string);
same?
which is better expression to make string into xml object[php]?
$xml = new SimpleXMLElement($xml_string);
vs
$xml = simplexml_load_string($xml_string);
same?
They're basically identical. SimpleXMLElement::__construct
accepts data strings or file paths, if you set the appropriate options. simplexml_load_file
and simplexml_load_string
are basically convenience function wrappers that amount to the same thing as new SimpleXMLElement()
with the correct options set.