PHP code example of aviator / html

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

    

aviator / html example snippets


$tag = new Tag('div');

$tag = Tag::make('div');

$tag = Tag::div();
 
$tag = tag('div');

echo $tag->render();

$tag = tag('div')->with('some content');

$tag = tag('div')->with(
    tag('p')->with('some content')
);

$tag = tag('ul')->with([
    tag('li')->with('list item 1'),
    tag('li')->with('list item 2'),
    'misplaced text',
]);

$fragment = new Fragment([
    new Tag('p'),
    new Tag('div'),
]);

// Or Fragment::make([...]);

$tag = new Tag('div');

// Evaluates equality, eg truthy and falsey values
$tag->setShouldRender(false); 

$tag = Tag::when(false, 'div');

$tag = tag('div', 'some-class');

$tag = tag('div', ['class-one', 'class-two'])

$tag = tag('div');

$tag->addClass('some-class');
$tag->addClass(['class2', 'class3']);

$tag = tag('input', 'some-class', [
    'value' => 'content',
    'disabled'
]);

$tag = tag('input');

$tag->addAttribute(['autocomplete' => 'off']);
$tag->addAttribute(['disabled']);

echo tag('input')->addAttribute(['name' => 'some_name'])->attribute('name');

// Result: 'some_name'

echo tag('input')->addAttribute(['disabled'])->attribute('disabled');

// Result: true

echo tag('input')->attribute('foo');

// Result: null

echo tag('div')->dontClose()->render()