PHP code example of keruyphp / keruy-html

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

    

keruyphp / keruy-html example snippets




declare(strict_types=1);

cho Html::div(['class' => 'box'], 'Hello world');

echo Html::ul([], [
	Html::li('One'),
	Html::li('Two'),
	Html::li('Three'),
]);

echo Html::ul(function () {
	Html::li('One');
	Html::li('Two');
	Html::li('Three');
});

echo Html::ul(
	Html::li('One'),
	Html::li('Two'),
	Html::li('Three'),
);

echo Html::div(['class' => 'card'], [
	Html::h2('Title'),
	Html::p('Text from array children.'),
]);

echo Html::div(function () {
	Html::h2('Title');
	Html::p('Text from closure children.');
});

echo Html::div(function (\KeruyPHP\KeruyHtml\Tags\Tag $div) {
	$div->append(
		'Hello ',
		Html::strong('world'),
		'!',
	);
});

echo Html::p(function (\KeruyPHP\KeruyHtml\Tags\Tag $p) {
	$p->text('Price: ', '100 UAH');
});

echo Html::div(function (\KeruyPHP\KeruyHtml\Tags\Tag $div) {
	$div->raw('<strong>Trusted HTML</strong>');
});

echo Html::div([
	'class' => 'box',
	'id' => 'main',
], 'Hello');

echo Html::div(function (\KeruyPHP\KeruyHtml\Tags\Tag $div) {
	$div->class('box');
	$div->prop('id', 'main');

	Html::span('Hello');
});

echo Html::div('Hello')
	->class('box')
	->prop('id', 'main');

echo Html::div('Hello')
	->class('box')
	->class('has-background-light');

echo Html::a('Profile')
	->prop('href', '/profile')
	->prop('target', '_blank');

echo Html::input(['type' => 'text'])
	->prop('name', 'email')
	->prop('placeholder', 'Email');

echo Html::div(['class' => 'card'], function () {
	Html::h2('Title');
	Html::p('Formatted output example.');
})->pretty();