PHP code example of brick / html

1. Go to this page and download the library: Download brick/html 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/ */

    

brick / html example snippets


use Brick\Html\Tag;

$div = new Tag('div');

$div = new Tag('div', [
    'id' => 'main',
    'class' => 'block',
]);

$tag->setAttributes([
    'id' => 'main',
    'class' => 'block',
]);

$tag->setAttribute('id', 'main')
    ->setAttribute('class', 'block');

$tag->removeAttribute('id');

$tag->setTextContent('Hello, world!');
$tag->appendTextContent("\nWhat's up?");

$tag->setHtmlContent('Hello, <b>world!</b>');
$tag->appendHtmlContent("<br>What's up?");

$tag->append($otherTag);

$tag->empty();

$tag->isEmpty(); // boolean

echo $tag; // will output something like: <div id="main">Hello, world!</div>