1. Go to this page and download the library: Download theaomx/htmlnode 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/ */
theaomx / htmlnode example snippets
use \TheAomx\Nodes\HtmlNode as HtmlNode;
use \TheAomx\Nodes\Indentation as Indentation;
$html = HtmlNode::get_builder("html")->attr("lang", "de")->build();
$head = HtmlNode::get_builder("head")->build();
$charset = HtmlNode::get_builder("meta")->attr("charset", "utf-8")->build();
$viewport = HtmlNode::get_builder("meta")->attr("name", "viewport")->
attr("content", "width=device-width, initial-scale=1.0")->build();
$title = HtmlNode::get_builder("title")->text("Hello World Site")->build();
$head->addChildNode($charset)->addChildNode($viewport)->addChildNode($title);
$body = HtmlNode::get_builder("body")->build();
$html->append($head)->append($body);
$h1 = HtmlNode::get_builder("h1")->text("Welcome stranger!")->build();
$p = HtmlNode::get_builder("p")->attr("style", "color: red;")->
attribute("align", "left")->build();
$b = HtmlNode::get_builder("b")->s_text("Hello World with umlaute äöü&%")->build();
$p->append($b);
$body->append($h1)->append($p);
// only at this step the root ast-node $html gets converted to a string!
echo $html;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.