PHP code example of machy8 / xhtml-formatter

1. Go to this page and download the library: Download machy8/xhtml-formatter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

machy8 / xhtml-formatter example snippets


use XhtmlFormatter\Formatter;

$formatter = new Formatter();

$output = $formatter->format($string);

$formatter

	// Change the content type from CONTENT_HTML (default) to CONTENT_XML or CONTENT_XHTML
	->setContentType(Formatter::CONTENT_XML)

	// Add new unpaired element
	->addUnpairedElement('element', Formatter::CONTENT_XML)

	// Add skipped elements
	->addSkippedElement('elementA elementB')

	// Indent file by 4 spaces instead of tabs
	->setSpacesIndentationMethod(4);