How to use construct in PHP

In this article I am going to explain about construct function in PHP.
  • 1469

construct() Function

This function creates a new Simple XML Element object.

This function returns an object on success, and FALSE on failure.

Syntax

__construct(file,class,options,ns,is_prefix)

Example

<html>
<?php
$xmlstring = <<<XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>sachin</to>
<from>satya</from>
<heading>Reminder</heading>
<body>Now i am Busy! Call me later</body>
</note>
XML;
$xml = new SimpleXMLElement($xmlstring);
echo $xml->body[0];
?>
<html>

Output

construct-php.jpg

You may also want to read these related articles Click here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.