xref: /PHP-8.0/ext/xmlwriter/tests/OO_005.phpt (revision a555cc0b)
1--TEST--
2XMLWriter: libxml2 XML Writer, comments
3--SKIPIF--
4<?php
5if (!extension_loaded("xmlwriter")) die("skip");
6if (!function_exists("xmlwriter_start_comment")) die("skip: libxml2 2.6.7+ required");
7?>
8--FILE--
9<?php
10
11$doc_dest = 'OO_005.xml';
12$xw = new XMLWriter();
13$xw->openUri($doc_dest);
14$xw->startDocument('1.0', 'UTF-8');
15$xw->startElement("tag1");
16$xw->startComment();
17$xw->text('comment');
18$xw->endComment();
19$xw->writeComment("comment #2");
20$xw->endDocument();
21
22// Force to write and empty the buffer
23$output_bytes = $xw->flush(true);
24echo file_get_contents($doc_dest);
25unset($xw);
26unlink($doc_dest);
27?>
28--EXPECT--
29<?xml version="1.0" encoding="UTF-8"?>
30<tag1><!--comment--><!--comment #2--></tag1>
31