PHP code example of spatie / html-element
1. Go to this page and download the library: Download spatie/html-element 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/ */
spatie / html-element example snippets
el('div.container > div.row > div.col-md-6',
el('a', ['href' => '#'], 'Hello world!')
);
function el(string $tag, $attributes = null, $content = null) : string
{
return \Spatie\HtmlElement\HtmlElement::render($tag, $attributes, $content);
}
el('div');
el('p', 'Hello world!');
el('p', ['style' => 'color: red;'], 'Hello world!');
el('p#introduction', 'Hello world!');
el('p#introduction.red', 'Hello world!');
el('a[href=#][title=Back to top]', 'Back to top');
el('div.container > div.row > div.col-md-6', 'Hello world!');
el('.container > .row > .col-md-6', 'Hello world!');
el('div', ['class' => 'container'],
el('nav', ['aria-role' => 'navigation'], '...')
);
el('ul', [el('li'), el('li')]);
el('img[src=/background.jpg]');
el('img', ['src' => '/background.jpg'], '');
el('p');
el('p', 'Hello world!');
el('ul', [el('li'), el('li')]);
el('div', ['class' => 'container'],
el('nav', ['aria-role' => 'navigation'], '...')
);