VOOZH about

URL: https://www.geeksforgeeks.org/php/php-xmlwriter-setindent-function/

⇱ PHP | XMLWriter setIndent() Function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

PHP | XMLWriter setIndent() Function

Last Updated : 7 Mar, 2024
The XMLWriter::setIndent() function is an inbuilt function in PHP which is used to toggle indentation on/off in the XML document which is off by default. Syntax:
bool XMLWriter::setIndent( bool $indent )
Parameters: This function accepts a single parameter $indent which holds a boolean stating TRUE for enabling the indentation or FALSE for disabling the indentation. Return Value: This function returns TRUE on success or FALSE on failure. Below examples illustrate the XMLWriter::setIndent() function in PHP: Example 1: Output:
<?xml version="1.0" encoding="UTF-8"?>
<div>
 <h1>Indented Text</h1>
</div>
Example 2: Output:
<?xml version="1.0" encoding="UTF-8"?>
<div>
******<p>
************<h1>GeeksforGeeks</h1>
******</p>
</div>
Comment
Article Tags: