PHP code example of natepage / easy-html-element

1. Go to this page and download the library: Download natepage/easy-html-element 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/ */

    

natepage / easy-html-element example snippets

 php
$map = array(
    'myDiv' => array(
        'type' => 'div',
        'text' => 'Simple Div Example'
    )
);

$htmlElement = new NatePage\EasyHtmlElement\HtmlElement();
$div = $htmlElement->load('myDiv');

echo $div; 

/**
 * <div>
 *      Simple Div Example
 * </div>
 */
 php
$map = array(
    //Base div
    'div' => array(
        'type' => 'div'
    ),
    //Base panel structure
    'panel' => array(
        'extends' => array('div'),
        'attr' => array('class' => 'panel'),
        'children' => array(
            'panelHeading',
            'panelBody',
            'panelFooter'
        )
    ),
    //Panel heading
    'panelHeading' => array(
        'extends' => array('div'),
        'attr' => array('class' => 'panel-heading'),
        'children' => array(
            array(
                'name' => 'panelHeadingTitle',
                'type' => 'h3',
                'attr' => array('class' => 'panel-title'),
                'text' => '%panel_title%'
            )
        )
    ),
    //Panel body
    'panelBody' => array(
        'extends' => array('div'),
        'attr' => array('class' => 'panel-body'),
        'text' => '%panel_body%'
    ),
    //Panel footer
    'panelFooter' => array(
        'extends' => array('div'),
        'attr' => array('class' => 'panel-footer'),
        'text' => '%panel_footer%'
    ),
    //Primary panel structure
    'panelPrimary' => array(
        'extends' => array('panel'),
        'attr' => array('class' => 'panel-primary')
    )
);

$htmlElement = new \NatePage\EasyHtmlElement\HtmlElement($map);
$panelPrimary = $htmlElement->load('panelPrimary', null, array(), array(
    'panel_title' => 'My Panel Title',
    'panel_body' => 'My Panel Body',
    'panel_footer' => 'My Panel Footer'
));

echo $panelPrimary;

/**
 * <div class="panel-primary panel">
 *      <div class="panel-heading">
 *          <h3 class="panel-title">My Panel Title</h3>
 *      </div>
 *      <div class="panel-body">
 *          My Panel Body
 *      </div>
 *      <div class="panel-footer">
 *          My Panel Footer
 *      </div>
 * </div>
 */