Home > Article > Backend Development > The underscore before the Php constructor construct is a double underscore
When I write PHP classes recently, I always encounter the error of function non object. I know that the class is not instantiated, but I just don’t know where the error is.
construct() function creates a new SimpleXMLElement object.
If successful, the function returns an object. On failure, returns false.
construct(data,options,is_url,ns,is_prefix)
Parameters | Description |
---|---|
data | Required. A well-formed XML string or the path or URL of an XML document. |
options | Optional. Specifies additional Libxml parameters. |
is_url | Optional. Specifies whether the data parameter is a URL. The default is false. |
ns | Optional. |
is_prefix | Optional. |
Returns a SimpleXMLElement object representing the data.
<?php $xmlstring = <<<XML <?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 SimpleXMLElement($xmlstring); echo $xml->body[0]; ?>
Output similar to:
Don't forget the meeting! 后来看construct的前_是一个,我靠,上次也是这个错误,忘了,现在记着了 function construct() {} 不是 function _construct() {}
The above is the detailed content of The underscore before the Php constructor construct is a double underscore. For more information, please follow other related articles on the PHP Chinese website!