XMLWriter::endDtdEntity()函數是PHP中的一個內置函數,用於結束當前DTD實體。 DTD代表“文檔類型定義”,它定義了XML文檔的結構以及法律元素和屬性。 DTD在網頁上不可見,因為它們的作用類似於注釋。實體用於定義特殊字符的快捷方式。
用法:
bool XMLWriter::endDtdEntity( void )
參數:此函數不接受任何參數。
返回值:如果成功,此函數將返回TRUE,否則將返回FALSE。
以下示例說明了PHP中的XMLWriter::endDtdEntity()函數:
範例1:
<?php
// Create a new XMLWriter instance
$writer = new XMLWriter();
// Create the output stream as PHP
$writer->openURI('php://output');
// Start the document
$writer->startDocument('1.0', 'UTF-8');
// Start the Dtd Entity
$writer->startDtdEntity('entity', true);
// End the Dtd Entity
$writer->endDtdEntity();
// End the document
$writer->endDocument();
?>
輸出:
<?xml version="1.0" encoding="UTF-8"?> <!ENTITY % entity>
範例2:
<?php
// Create a new XMLWriter instance
$writer = new XMLWriter();
// Create the output stream as PHP
$writer->openURI('php://output');
// Start the document
$writer->startDocument('1.0', 'UTF-8');
// Start the Dtd Entity which is
// not going to be visible
$writer->startDtdEntity('entity', true);
// End the Dtd Entity
$writer->endDtdEntity();
// Start a h1 element
$writer->startElement('h1');
// Add a style attribute
$writer->writeAttribute('style',
'color:blue;font-size:100;');
// Add text to the element
$writer->text('GeeksforGeeks');
// End the element
$writer->endElement();
// End the document
$writer->endDocument();
?>
輸出:
參考: https://www.php.net/manual/en/function.xmlwriter-end-dtd-entity.php
相關用法
- PHP XMLWriter startDocument()用法及代碼示例
- PHP XMLWriter startComment()用法及代碼示例
- PHP XMLWriter startCdata()用法及代碼示例
- PHP XMLWriter endElement()用法及代碼示例
- PHP XMLWriter openUri()用法及代碼示例
- PHP XMLWriter setIndent()用法及代碼示例
- PHP XMLWriter fullEndElement()用法及代碼示例
- PHP XMLWriter startAttributeNs()用法及代碼示例
- PHP XMLWriter endPi()用法及代碼示例
- PHP XMLWriter startAttribute()用法及代碼示例
- PHP XMLWriter endComment()用法及代碼示例
- PHP XMLWriter startDtdAttlist()用法及代碼示例
- PHP XMLWriter endDocument()用法及代碼示例
- PHP XMLWriter endCdata()用法及代碼示例
- PHP XMLWriter endAttribute()用法及代碼示例
注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | XMLWriter endDtdEntity() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。