PHP code example of canteen / html5

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

    

canteen / html5 example snippets




// Enable the global use of html()
Canteen\HTML5\HTML5::useGlobal();

// Turn on autoloading if not using composer's autoloading
Canteen\HTML5\HTML5::autoload();

echo html('img src=home.jpg');
echo html('img', 'src=home.jpg'); 
echo html('img', array('src'=>'home.jpg')); 

    echo html('nav title="Navigation" class=main', 'Welcome');
    

    echo html('nav', 'Welcome', array('title'=>'Navigation', 'class'=>'main'));
    

    echo html('nav', 'Welcome', 'title="Navigation" class=main');
    

  $nav = html('nav', 'Welcome');
  $nav->class = 'main';
  $nav->title = 'Navigation';
  echo $nav;
  

$label = html('span', 'Website!');
$link = html('a', $label);
$link->href = 'http://example.com';
echo $link; 

$link = html('a');
$link->href = 'http://example.com';
$link->addChild(html('span', 'Website!'));
echo $link;

$link = html('a');
$link->href = 'http://example.com';
html('span', 'Website!')->appendTo($link);
echo $link;

echo html('a#example'); //<a id="example"></a>
echo html('span.small'); //<span class="small"></span>
echo html('span.small.label'); //<span class="small label"></span>
echo html('span#example.small.label'); //<span id="example" class="small label"></span>

html($tag, $attributes=null);

html($tag, $contents=null, $attributes=null);

Canteen\HTML5\Document($title='', $charset='utf-8', $beautify=false);

	use Canteen\HTML5\Document;
	$doc = new Document('Untitled');
    $doc->head->addChild(html('script src=main.js'));
    $doc->body->addChild(html('div#frame'));
    echo $doc;

Canteen\HTML5\SimpleList($elements, $attributes=null, $type="ul");

Canteen\HTML5\Table($data, $headers=null, $checkbox=null);

// Create a sample table with some rows of dummy data
$table = new Table(
    array(
        array('id'=>1, 'first'=>'James', 'last'=>'Smith'),
        array('id'=>2, 'first'=>'Mary', 'last'=>'Denver'),
        array('id'=>3, 'first'=>'Charlie', 'last'=>'Rose')
    ),
    array('ID', 'First Name', 'Last Name')
);