The leading underscore of the Php constructor construct is double__PHP Tutorial

WBOY
Release: 2016-07-21 15:42:26
Original
1399 people have browsed it

Definition and usage

__construct() function creates a new SimpleXMLElement object.

If successful, the function returns an object. If failed, returns false.

Grammar

__construct(data,options,is_url,ns,is_prefix)
Copy after login
参数 描述
data 必需。形式良好的 XML 字符串或 XML 文档的路径或 URL。
options 可选。规定附加的 Libxml 参数。
is_url 可选。规定 data 参数是否是 URL。默认是 false。
ns 可选。
is_prefix 可选。

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

The output is similar to:

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320957.htmlTechArticleDefinition and usage The __construct() function creates a new SimpleXMLElement object. If successful, the function returns an object. If failed, returns false. Syntax __constru...
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