PHP code example of adilab / html

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

    

adilab / html example snippets




use Adi\Html\Tag;

$p = new Tag('p', 'Hello world');
$p->addStyle('color: #ff0000')->addStyle('background-color', '#ccc');
echo $p->render();



use Adi\Html\Div;
use Adi\Html\Strong;

echo Div::create(Strong::create('Hello world'))->setStyle('color: #ff0000');


use Adi\Html\Table\Table;
use Adi\Html\Table\Tr;
use Adi\Html\Table\Td;

$data = array(
    array('aaa', 'bbb', Td::create('ccc')->addClass('ccc')),
    array('ddd', 'eee', 'fff'),
    Tr::create(array('ggg', 'hhh', 'iii'))->addClass('selected'),
);

echo Table::create($data);


use Adi\Html\Table\Table;
use Adi\Html\Table\Th;
use Adi\Html\Table\Tr;
use Adi\Html\Table\Column;
use Adi\Html\Table\Td;

$data = array(
    array('A' => 'aaa', 'B' => 'bbb', 'C' => 'ccc'),
    array('A' => 'ddd', 'B' => 'eee', 'C' => 'fff'),
    array('A' => 'ggg', 'B' => 'hhh', 'C' => Td::create('iii')->setId('i')),
);

$table = new Table($data);
$table->setColumn('B', Column::create()->addStyle('color', '#ff0000'));
$table->setHeader('B', '[B]');
$table->setHeader('C', Th::create('[C]')->addStyle('color', '#0000ff'));
echo $table;