PHP code example of nethead / markup

1. Go to this page and download the library: Download nethead/markup 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/ */

    

nethead / markup example snippets


use Nethead\Markup\MarkupFactory as Html;
// or
use function Nethead\Markup\Helpers\tag;

// Link to Google.com
Html::anchor('https://google.com', ['Go to Google'])->blank();

// Image link
Html::anchor('https://google.com', [
    Html::image('/img/google.png', 'Google Logo')
])->blank();

// Paragraph
tag('p', ['class' => 'px-2'], [
    'Here is how you can search with',
    tag('a', ['href' => 'https://google.com'], ['Google'])->blank()
]);

$menuItem = tag('li', ['class' => 'nav-item'], ['Discount!']);
// (...)
$menuItem->attrs()
    ->set('class', 'bold');

if ($menuItem->classList()->caintains('bold')) {
    $menuItem->attrs()->data('modal', 'discount');
}

use Nethead\Markup\Helpers\HtmlConfig;

HtmlConfig::$closeVoids = true;

use Nethead\Markup\Helpers\IconsFactory;
use Nethead\Markup\Helpers\HtmlConfig;

HtmlConfig::$defaultIconsFactory = 'glyphicons';

print IconsFactory::icon('user');

use Nethead\Markup\MarkupFactory as Html;

$langs = [
    'en_GB' => 'English (British)',
    'pl_PL' => 'Polski'
];

$select = Html::select('locale', $langs);
$select->attrs()
    ->on('change', 'this.form.submit();');

$form = Html::form('/select-locale', 'POST', [$select]);