Home > Article > Backend Development > What does construct mean in PHP?
Construct in PHP refers to the __construct() function, which is used to create a new SimpleXMLElement object. Its syntax is "__construct(data, options, is_url, ns, is_prefix)".
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
What does construct mean in PHP?
PHP __construct() function
#__construct() function creates a new SimpleXMLElement object.
If successful, the function returns an object. If failed, returns false.
Syntax
__construct(data,options,is_url,ns,is_prefix)
参数 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 SimpleXMLElement($xmlstring); echo $xml->body[0]; ?>
Output is similar:
Don't forget the meeting!
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What does construct mean in PHP?. For more information, please follow other related articles on the PHP Chinese website!