lukaswhite/html-element

A really simple PHP class for creating HTML elements

dev-master 2018-08-16 08:12 UTC

This package is auto-updated.

Last update: 2019-12-27 14:16:06 UTC


README

A really simple PHP class for creating HTML elements.

$heading = new HtmlElement( 'h2', 'This is a heading' );
$heading->set( 'class', 'is-title' );
print $heading->render( );
// or, because it implements __toString( )
print $heading

This will output the following:

<h2 class="is-title">This is a heading</h2>

You can also provide another instance when setting content:

$span = new HtmlElement( 'span', 'span content' );
$p = new HtmlElement( 'p' );
$p->setContent( $span );