When I write PHP classes recently, I always encounter the error of function nonobject. I know that the class is not instantiated, but I just don’t know where the error is.
construct() function creates a newSimpleXMLElementobject.
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 XMLstringor 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.
XML; $xml = new SimpleXMLElement($xmlstring); echo $xml->body[0]; ?> George John Reminder Don't forget the meeting!
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!