PHP code example of best-served-cold / html-builder
1. Go to this page and download the library: Download best-served-cold/html-builder 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/ */
best-served-cold / html-builder example snippets
composer
use BestServedCold\HTMLBuilder\Html;
use BestServedCold\HTMLBuilder\Output;
$p = Html::p()->content('some content');
echo (new Output($p))->get();
$div = Html::div()->class('someClass')->id('someId');
echo (new Output($div))->get();
$div2 = Html::div(
Html::p()->content('child content')->class('someClass'),
function () {
return Html::input()
->type('text')
->name('test')
->disabled();
}
)->onblur('somefunc();');
echo (new Output($div2))->get();
$div3 = Html::div(
Html::p(
Html::span()
->data('bob')
->content('span content')
),
Html::comment(' this is some comment ')
);
Output::setTabSize(2); // persistent
Output::setDepth(2); // persistent
echo (new Output($div3))->get();
Output::setTabSize(4);
Output::setDepth(0);