PHP code example of yivi / very-simple-html-writer
1. Go to this page and download the library: Download yivi/very-simple-html-writer 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/ */
yivi / very-simple-html-writer example snippets
$writer = new HtmlWriterService();
$main_layout = $writer->layout('main');
$openBody = $writer->tag('body')->leaveOpen();
$title = $writer->fragment('hello, world!');
$h1 = $writer->tag('h1')->content($title);
$main_layout->addParts($openBody, $h1);
$ul_nav = $writer->tag('ul')
->attribute('role', 'navigation')
->addClass('navigation')
->id('navigation');
$nav_li_layout = $writer->layout('nav');
$li_home = $writer->tag('li')->content($writer->fragment('Home'));
$li_contact = $writer->tag('li')->content($writer->fragment('Contact'));
$li_about = $writer->tag('li')->content($writer->fragment('About'));
$nav_li_layout->addParts($li_home, $li_contact, $li_about);
$ul_nav->content($nav_li_layout);
$closeBody = $writer->tag('body')->justClose();
$main_layout->addParts($ul_nav, $closeBody)
echo $main_layout->compile();