PHP code example of gin0115 / elmishphp-html

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

    

gin0115 / elmishphp-html example snippets


use function Gin0115\ElmishPHP\HTML\div;
use function Gin0115\ElmishPHP\HTML\span;
use function Gin0115\ElmishPHP\HTML\p;
use function Gin0115\ElmishPHP\HTML\text;

echo div(['id' => 'wrap', 'class' => 'card'])(
    p()(text('Hello, '), span(['class' => 'name'])(text('world'))),
);

div ([ 'id' => 'wrap', 'class' => 'card' ])
    ( p ()
        ( text('Hello, ')
        , span ([ 'class' => 'name' ])(text('world'))
        )
    );

echo div()(text('<script>alert(1)</script>'));
// <div>&lt;script&gt;alert(1)&lt;/script&gt;</div>

echo div()(raw('<b>bold</b>'));
// <div><b>bold</b></div>

div([
    'id'        => 'foo',   // standard key=value — value is HTML-escaped
    'data-flag' => null,    // null value → bare flag attribute
    'data-other',           // positional entry → bare flag attribute
])(text('hi'));

echo br();                                            // <br>
echo img(['src' => 'logo.png', 'alt' => 'logo']);     // <img src="logo.png" alt="logo">
echo input(['type' => 'text', 'name' => 'q', '

use function Gin0115\ElmishPHP\HTML\node;

echo node('custom-element', ['data-x' => 'y'])(text('whatever'));
// <custom-element data-x="y">whatever</custom-element>