Home >Backend Development >PHP Tutorial >constructor Php The leading underscore of the constructor construct is double_

constructor Php The leading underscore of the constructor construct is double_

WBOY
WBOYOriginal
2016-07-29 08:41:221455browse

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 <code>SimpleXMLElement($xmlstring)</code>;

echo $xml->body[0];
?>

Output similar to:

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

The above introduces the constructor Php constructor function. The leading underscore of construct is double _, including the content of constructor. I hope it will be helpful to friends who are interested in PHP tutorials.

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