What is the difference between this and writing
$xml = simplexml_load_string($string)?
What is the difference between this and writing
$xml = simplexml_load_string($string)?
simplexml_load_string
is xml
data of type string
,
The second parameter is the object type returned by the method. The default is SimpleXMLElement
. You can customize it, but the class must inherit from SimpleXMLElement
,
The third parameter is some operation options, for reference, here is the merge cdata
data
First understand the meaning of the two parameters after simplexml_load_string
Look here: http://php.net/manual/zh/func...
Second parameter: Specify a return object of a class. If the default value is not set, an object of the SimpleXMLElement class is returned.
See here: http://php.net/manual/zh/clas...
The third parameter: Pass in some predefined constants, which can control some controls when the object is returned
See here: http://php.net/manual/zh/libx...
So your second parameter here is the default return object, which is no different than if you only set the first parameter. The key is that the third parameter you set controls what if there is
The second parameter indicates the class used for parsing. The class must inherit from SimpleXMLElement, and the default value is SimpleXMLElement.
The third parameter indicates the parsing option. LIBXML_NOCDATA indicates that CDATA will not be translated, but will be parsed as ordinary text.
These things are all in the documentation. If you come here to ask, in Brother Niao’s words, you have found the slowest way to acquire knowledge.
http://php.net/manual/en/func...