Generate HTML markup with PHP objects
- PHP >= 7.2
- Composer
$ composer require jjgrainger/html
The Element class can be used to generate any type of HTML markup.
useHTML\Element;
// Creat a link element.$link = newElement('a');
// Set the href attribute.$link->setAttribute('href', 'https://google.com');
// Set the class attribute.$link->setAttribute('class', 'text-link');
// Append attribute values, in this case adding a 'active' class to the element.$link->appendAttribute('class', 'active');
// Set the content for the$link->setContent('Hello World!');
// Outputs HTMLecho$link;The above will output the following.
<ahref="https://google.com" class="text-link active">Hellow World!</a>- The library is still in active development and not intended for production use.
- Licensed under the MIT License
- Maintained under the Semantic Versioning Guide
Joe Grainger