1. Go to this page and download the library: Download aduh95/html-generator 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/ */
aduh95 / html-generator example snippets
= new aduh95\HTMLGenerator\Document('My title', 'en');
// If you want PHP to render you HTML in a way a human can read it
// Default is compressed
$doc->getDOMDocument()->formatOutput = true;
// Add attribute array-like
$doc->getHead()->appendChild($doc->createElement('meta'))['charset'] = 'uft-8';
// Or add attribute jQuery-like
$doc->getHead()->link()->attr('rel', 'icon')->attr(['type'=>'image/png', 'href'=>'/asset/icon.png']);
$doc()->p()->text('<script>alert("no XSS!");</script>') // add XSS-protected text easily
()->p()->append() // add children to an element with a simple method call
()->b('You are looking for something, aren\'t you?') // Add text content
()->br() // Auto closing tags are handled
()->a(
['href'=>'http://google.fr/', 'alt'=>'Search the "web"'], // An other method to add attributes
'YES, YOU CAN FIND IT!'
)->data('user-color', 'red') // as in jQuery, you can set a "data-" attribute
()->br()
()->smaller(['class'=>'alert alert-info'])->text('This link is sponsored.')
()
()->p('I ♥ Rock\'n\'Roll!')
->attr('test', 4)
->data('HTMLCamelCaseDataInformation', 'valid') // Transform CamelCase dataset to snake_case to match W3C standard
;
// List shortcut
$list = $doc()->ul();
$list[] = $doc->createTextNode('First <item>');
$list[] = $doc->createElement('b')->text('second one');
$list->append('third one');
$list->append()
()->li('fourth one');
// Table shortcut
$table = $doc()->table();
$table[] = ['This', 'is', 'a', 'row'];
$table[] = [$doc->createElement('td')->attr('rowspan', 3)->text('another'), 'one'];
$table
->append(['data', 'in', 'the', 'row'])
->append([['multi', 'row'], ['so', 'easy']]);
// This line is optionnal, the document will be automatically output at the end of ths script
echo $doc;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.