PHP code example of sandrokeil / html-element

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

    

sandrokeil / html-element example snippets


return [
   'view_helpers' => [
        'factories' => [
            \Sake\HtmlElement\View\Helper\HtmlElement::class => \Sake\HtmlElement\Service\HtmlElementFactory::class,
        ],
    ],
];



// assume we are in a template
echo $this->html('div', 'my content', array('id' => 'content', 'class' => 'box shadow'));

// or
$div = $this->html('div');
echo $div->setText('my content')
    ->setAttributes(array('id' => 'content', 'class' => 'box shadow'));

// to render HTML you can use
echo $div->enableHtml(true)
    ->setText(
        $this->html('p')->setText('Hello World!')->appendClass('welcome');
    );

// or
echo $this->html(
    'div',
    $this->html('p')->setText('Hello World!')->appendClass('welcome'),
    array('id' => 'content', 'class' => 'box shadow'),
    true
);



return array(
    'sake_htmlelement' => array(
        'view_helper' => array(
            'default' => array(
                'escapeHtmlAttribute' => false,
                'escapeText' => false,
            ),
        ),
    ),
    // other module config stuff
);