lukaswhite / html-element
A really simple PHP class for creating HTML elements
Installs: 291
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/lukaswhite/html-element
Requires (Dev)
- phpunit/php-code-coverage: ^6.0
- phpunit/phpunit: 7.0
This package is auto-updated.
Last update: 2025-09-28 02:45:58 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 );