Home >Backend Development >PHP Tutorial >The underscore before the Php constructor construct is a double underscore

The underscore before the Php constructor construct is a double underscore

怪我咯
怪我咯Original
2017-07-06 09:55:382160browse

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.

Definition and usage

construct() function creates a new SimpleXMLElement object.

If successful, the function returns an object. On failure, returns false.

Syntax

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.

Return value

Returns a SimpleXMLElement object representing the data.

Example

<?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!

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