PHP | DOMEntityReference __construct() function
Last Updated :
19 Feb, 2020
The DOMEntityReference::__construct() function is an inbuilt function in PHP which is used to create a new DOMEntityReference object.
Syntax:
public DOMEntityReference::__construct( string $name )
Parameters:This function accepts a single parameter $name which holds the name of the entity reference.
Below given programs illustrate the DOMEntityReference::__construct() function in PHP:
Program 1:
<?php
$dom = new DOMDocument();
$element = $dom ->appendChild( new DOMElement( 'H1' ));
$entity = $element ->appendChild( new DOMEntityReference( 'GeeksforGeeks' ));
echo $dom ->saveXML();
?>
|
Output:
Program 2:
<?php
$dom = new DOMDocument();
$element = $dom ->appendChild( new DOMElement( 'body' ));
$entity = $element ->appendChild( new DOMEntityReference( 'GeeksforGeeks' ));
echo $entity ->nodeName;
?>
|
Output:
GeeksforGeeks
Reference: https://www.php.net/manual/en/domentityreference.construct.php
Share your thoughts in the comments
Please Login to comment...