Home >Backend Development >PHP Tutorial >What are the uses of these two parameters of simplexml_load_string in php?

What are the uses of these two parameters of simplexml_load_string in php?

WBOY
WBOYOriginal
2016-08-25 10:37:231012browse

What are the uses of these two parameters of simplexml_load_string in php?

What is the difference between this and writing
$xml = simplexml_load_string($string)?

Reply content:

What are the uses of these two parameters of simplexml_load_string in php?

What is the difference between this and writing
$xml = simplexml_load_string($string)?

    The first parameter received by
  • simplexml_load_string is xmldata 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 cdatadata

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 , then there is no goods_name value in the final converted object. If LIBXML_NOCDATA is added, the value is Mavericks N1, which is equivalent to Convert to text and return

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...

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn