PHP | XMLWriter endComment() Function
Last Updated :
07 Mar, 2024
The XMLWriter::endComment() function is an inbuilt function in PHP which is used to end a comment which is started using XMLWriter::startComment() function.
Syntax:
bool XMLWriter::endComment( void )
Parameters: This function doesn’t accept any parameter.
Return Value: This function returns TRUE on success or FALSE on failure.
Below examples illustrate the XMLWriter::endComment() function in PHP:
Example 1:
<?php
$writer = new XMLWriter();
$writer ->startDocument( '1.0' , 'UTF-8' );
$writer ->startElement( 'div' );
$writer ->startComment();
$writer ->text( 'This is a comment' );
$writer ->endComment();
$writer ->endElement();
$writer ->endDocument();
?>
|
Output:
Example 2:
<?php
$writer = new XMLWriter();
$writer ->startDocument( '1.0' , 'UTF-8' );
$writer ->startElement( 'div' );
$writer ->startComment();
$writer ->text( 'This will not be visible.' );
$writer ->endComment();
$writer ->text( 'GeeksforGeeks' );
$writer ->endElement();
$writer ->endDocument();
?>
|
Output:
GeeksforGeeks
Share your thoughts in the comments
Please Login to comment...