PHP code example of one234ru / html-tag-generator
1. Go to this page and download the library: Download one234ru/html-tag-generator 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/ */
one234ru / html-tag-generator example snippets
$config = [ ... ];
$html_tag = new \One234ru\HTMLtagGenerator($config);
echo $html_tag;
[
'text' => 'Here is some text'
]
[
'tag' => 'span',
'text' => 'Here is some text'
]
[
'text' => 'Here is some text',
'attr' => [
'id' => 'main',
'class' => 'someclass',
'style' => 'font-weight: bold',
'data-something' => [ 'x' => 1, 'y' => 2 ]
]
]
[
'tag' => 'input',
'attr' => [
'type' => 'checkbox',
'checked' => true
]
]
[
'tag' => 'input',
'attr' => [
'type' => 'checkbox',
'checked' => false
]
]
[
'text' => 'Did you like it?',
'children' => [
[
'tag' => 'input',
'attr' => [
'type' => 'submit',
'value' => 'Yes!', // Да!
],
],
[
'tag' => 'input',
'attr' => [
'type' => 'reset',
'value' => 'No', // Нет
]
],
[
'tag' => 'button',
'text' => "I don't know", // Не знаю
]
]
]
[
'tag' => 'ul',
'children' => [
'<li>One</li>',
'<li>Two</li>',
'<li>Three</li>',
]
]
[
'children' => [
'This is the text at the beginning. ',
'<b>This is a bold text.</b> ',
'This is the text at the end.',
]
]
[
'text' => 'Here is some text'
]
[
'children' => [
'Here is some text'
]
]
[
'text' => 'Here is some text'
]
'<div>Here is some text</div>'
class Test extends \One234ru\HTMLtagGenerator {
protected function normalizeConfig($config)
{
if (isset($config['class'])) {
$config['attr']['class'] = $config['class'];
unset($config['class']);
}
return $config;
}
}
echo new Test([
'class' => 'something',
]);
// Same thing using the basic class:
echo new \One234ru\HTMLtagGenerator([
'attr' => [
'class' => 'something'
]
]);