Skip to content

jjgrainger/HTML

Repository files navigation

HTML v0.1.0

tests codecov Latest Stable Version Total Downloads License

Generate HTML markup with PHP objects

Requirements

Installation

$ composer require jjgrainger/html

Usage

The Element class can be used to generate any type of HTML markup.

use HTML\Element;

// Creat a link element.
$link = new Element('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 HTML
echo $link;

The above will output the following.

<a href="https://google.com" class="text-link active">Hellow World!</a>

Notes

Author

Joe Grainger

About

Generate HTML markup with PHP objects

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages