The underscore before the Php constructor construct is a double underscore

怪我咯
Release: 2023-03-12 19:52:02
Original
2128 people have browsed it

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)
Copy after login
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];
?>
Copy after login

Output similar to:

Don't forget the meeting!
后来看construct的前_是一个,我靠,上次也是这个错误,忘了,现在记着了 
function construct() 
{} 

不是 
function _construct() 
{}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template