當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


PHP XMLWriter endDtd()用法及代碼示例

XMLWriter::endDtd()函數是PHP中的內置函數,用於結束當前的DTD,該DTD是使用XMLWriter::startDtd()函數啟動的。 DTD代表“文檔類型定義”,它定義了XML文檔的結構以及法律元素和屬性。 DTD在網頁中不可見,因為它們的作用類似於注釋。

用法:

bool XMLWriter::endDtd( void )

參數:此函數不接受任何參數。



返回值:如果成功,則此函數返回TRUE;如果失敗,則返回FALSE。

以下示例說明了PHP中的XMLWriter::endDtd()函數:

範例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 
$writer->startDtd('my_dtd'); 
   
// End the Dtd  
$writer->endDtd(); 
      
// End the document 
$writer->endDocument(); 
?>

輸出:按Ctrl + U查看XML

範例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 
$writer->startDtd('my_dtd_which_is_not_visible'); 
   
// End the Dtd  
$writer->endDtd(); 
  
// Write a text to document 
$writer->text('This is XMLWriter.'); 
  
// End the document 
$writer->endDocument(); 
?>

輸出:

This is XMLWriter.

參考: https://www.php.net/manual/en/function.xmlwriter-end-dtd.php




相關用法


注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | XMLWriter endDtd() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。