The first underscore of the Php constructor construct is double _
- 2020-03-31 17:01:27
- OfStack
Definition and usage
S function creates a new SimpleXMLElement object.
If successful, the function returns an object. If this fails, false is returned.
grammar
__construct (data, options, is_url, ns, is_prefix) parameter describe The data A necessity. The path or URL of a well-formed XML string or XML document. The options Optional. Specify the additional Libxml parameters. is_url Optional. Specify whether the data parameter is a URL. The default is false. ns Optional. is_prefix Optional.
The return value
Returns a SimpleXMLElement object representing data.
example
< ? PHP $xmlstring = < < < XML < ? The XML version = "1.0" encoding = "ISO - 8859-1"? > < Note> < To> George< / to> < From> John< / from> < Heading> Reminder< / heading> < Body> Don 't forget the meeting! < / body> < / note> XML; $XML = new < code > SimpleXMLElement ($xmlstring) < / code >; Echo $XML - > The body [0]. ? >
The output is similar to:
Don 't forget the meeting!
Then I saw that the front _ of construct was one. Oh, my god. It was the same mistake last time
The function __construct ()
{}
not
The function _construct ()
{}