DOMEntityReference::__construct()函數是PHP中的內置函數,用於創建新的DOMEntityReference對象。
用法:
public DOMEntityReference::__construct( string $name )
參數:該函數接受單個參數$name,該參數保存實體引用的名稱。
下麵給出的程序說明了PHP中的DOMEntityReference::__construct()函數:
程序1:
<?php
// Create a new DOMDocument
$dom = new DOMDocument();
// Add the node to the dom
$element = $dom->appendChild(new DOMElement('H1'));
// Add the DOM Entity Reference as a child
$entity = $element->appendChild(new DOMEntityReference('GeeksforGeeks'));
// Render the XML
echo $dom->saveXML();
?>
輸出:
程序2:
<?php
// Create a new DOMDocument
$dom = new DOMDocument();
// Add the node to the dom
$element = $dom->appendChild(new DOMElement('body'));
// Add the DOM Entity Reference as a child
$entity = $element->appendChild(new DOMEntityReference('GeeksforGeeks'));
// View the name of node
echo $entity->nodeName;
?>
輸出:
GeeksforGeeks
參考: https://www.php.net/manual/en/domentityreference.construct.php
相關用法
- PHP abs()用法及代碼示例
- p5.js arc()用法及代碼示例
- PHP tan( )用法及代碼示例
- PHP cos( )用法及代碼示例
- d3.js d3.rgb()用法及代碼示例
- PHP end()用法及代碼示例
- d3.js d3.lab()用法及代碼示例
- d3.js d3.hcl()用法及代碼示例
- PHP sin( )用法及代碼示例
- PHP Ds\Set xor()用法及代碼示例
- CSS rgb()用法及代碼示例
注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | DOMEntityReference __construct() function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。