PHP code example of valerian / html
1. Go to this page and download the library: Download valerian/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/ */
valerian / html example snippets
$element = (new Valerian\Html\Html())
->attribute('class', 'foo')
->attribute('id', 'bar')
->addChild(...)
echo (string) $element;
$element = (new Valerian\Html\Body())
->attribute('class', 'foo')
->attribute('id', 'bar')
->addChild(...)
echo (string) $element;
$element = (new Valerian\Html\Div())
->attribute('class', 'foo')
->attribute('id', 'bar')
->addChild(...)
echo (string) $element;
$element = (new Valerian\Html\Span())
->attribute('class', 'foo')
->attribute('id', 'bar')
->addChild(...)
echo (string) $element;
$element = (new Valerian\Html\Paragraph())
->attribute('class', 'foo')
->attribute('id', 'bar')
->addChild(...)
echo (string) $element;
$element = (new Valerian\Html\Img('image url'))
->alt('alt text')
->width(100)
->height(200)
->attribute('class', 'foo')
->attribute('id', 'bar')
echo (string) $element;
$input = (new Valerian\Html\Input('text', 'foo'))
->value('bar')
->attribute('class', 'foo')
->attribute('id', 'bar')
echo (string) $input;
$select = (new Valerian\Html\Select('foo'))
->addOption(
(new \Valerian\Html\SelectOption(1, 'Option 1'))
->disabled('disabed')
)
->addOption(
(new \Valerian\Html\SelectOption(2, 'Option 2'))
)
->attribute('class', 'foo')
->attribute('id', 'bar')
echo (string) $select;
$input = (new Valerian\Html\Form('#'))
->method('GET')
->attribute('class', 'foo')
->attribute('id', 'bar')
->addChild($input)
->addChild($select)
echo (string) $input;