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
相关用法
- PHP XMLWriter endAttribute()用法及代码示例
 - PHP XMLWriter startDtdAttlist()用法及代码示例
 - PHP XMLWriter endDtdEntity()用法及代码示例
 - PHP XMLWriter startAttributeNs()用法及代码示例
 - PHP XMLWriter endDocument()用法及代码示例
 - PHP XMLWriter startCdata()用法及代码示例
 - PHP XMLWriter startAttribute()用法及代码示例
 - PHP XMLWriter endCdata()用法及代码示例
 - PHP XMLWriter startDocument()用法及代码示例
 - PHP XMLWriter endComment()用法及代码示例
 - PHP XMLWriter setIndent()用法及代码示例
 - PHP XMLWriter setIndentString()用法及代码示例
 - PHP XMLWriter startComment()用法及代码示例
 - PHP XMLWriter endDtdAttlist()用法及代码示例
 - PHP XMLWriter endDtdElement()用法及代码示例
 
注:本文由纯净天空筛选整理自gurrrung大神的英文原创作品 PHP | XMLWriter endDtd() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
