PHP code example of zamasskin / html-constructor
1. Go to this page and download the library: Download zamasskin/html-constructor 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/ */
zamasskin / html-constructor example snippets
use HtmlConstructor\Tags;
iv())
->style("color: red; background: #000")
->className("parent")
->children([
(new Tags\TextContent\Div())->className("one"),
(new Tags\TextContent\Div())->className("two"),
]);
echo $html->render();
// <div style="color: red; background: #000" class="parent"><div class="one"></div><div class="two"></div></div>
$html = Tags::Div()->className("root")->children([
Tags::Span('main caption')->className("caption"),
Tags::A('http://example.com', 'main link')->className("link")
]);
echo $html->render();
// <div class="root"><span class="caption">main caption</span><a href="http://example.com" class="link">main link</a></div>
$html = (new Tags\Tag("custom"))->setAttribute("data", "test");
echo $html->render();
// <custom data="%test"></custom>
$html = Tags::Tag("custom")->setAttribute("data", "test");
echo $html->render();
// <custom data="%test"></custom>