1. Go to this page and download the library: Download asmundstavdahl/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/ */
asmundstavdahl / html example snippets
smundStavdahl\HTML;
# Include element function definitions
new HTML\Elements;
$nodeTree = HTML\HTML(["lang" => "en"],
[ HTML\HEAD([],
[ HTML\TITLE([], ["Test of html-builder"])
, HTML\STYLE([], [
"h1 { color: red; }
.im-blue { color: lightblue; }"
])
])
, HTML\BODY([],
[ HTML\H1([], ["This is a test"])
, HTML\P([],
[ "Strings become text nodes."
, HTML\BR()
, HTML\TEXT("You can also be more explicit and make a text node using the TEXT function.")
])
, HTML\LABEL(["for" => "test_input"], ["Test input"])
, HTML\INPUT(["id" => "test_input", "type" => "text"])
])
]);
$htmlConfig = new HTML\HtmlConfig(
true, # pretty formating with indentation
" " # indent with two spaces
);
$html = $nodeTree->toHTML($htmlConfig);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.