PHP code example of yiisoft / html

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

    

yiisoft / html example snippets



use Yiisoft\Html\Html;
use Yiisoft\Html\Tag\Meta;

echo \Yiisoft\Html\Tag\Div::tag()
    ->content(
        \Yiisoft\Html\Tag\A::tag()
            ->mailto('[email protected]')
            ->content('contact us')
            ->render()
    )
    ->encode(false)
    ->id('ContactEmail')
    ->class('red');

echo \Yiisoft\Html\Tag\CustomTag::name('b')
    ->content('text')
    ->attribute('title', 'Important');

// <b>&lt;i&gt;hello&lt;/i&gt;</b>
echo Html::b('<i>hello</i>');

// <b><i>hello</i></b>
echo Html::b('<i>hello</i>')->encode(false);

// <b><i>hello</i></b>
echo Html::b(Html::i('hello'));

// <b>&lt;i&gt;hello&lt;/i&gt;</b>
echo Html::b(Html::i('hello'))->encode(true);

// <b><i>hello</i></b>
echo Html::b(NoEncode::string('<i>hello</i>'));

echo \Yiisoft\Html\Widget\ButtonGroup::create()
   ->buttons(
       \Yiisoft\Html\Html::resetButton('Reset Data'),
       \Yiisoft\Html\Html::resetButton('Send'),
   )
   ->containerAttributes(['class' => 'actions'])
   ->buttonAttributes(['form' => 'CreatePost']);

echo \Yiisoft\Html\Widget\CheckboxList\CheckboxList::create('count')
    ->items([1 => 'One', 2 => 'Two', 5 => 'Five'])
    ->uncheckValue(0)
    ->value(2, 5)
    ->containerAttributes(['id' => 'main']);

echo \Yiisoft\Html\Widget\RadioList\RadioList::create('count')
    ->items([1 => 'One', 2 => 'Two', 5 => 'Five'])
    ->uncheckValue(0)
    ->value(2)
    ->containerAttributes(['id' => 'main']);

echo \Yiisoft\Html\Html::a('Yii Framework', 'https://www.yiiframework.com/');