Download the PHP package brick/html without Composer
On this page you can find all versions of the php package brick/html. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package html
Brick\Html
A very simple HTML 5 generation library.
Installation
This library is installable via Composer:
Requirements
This library requires PHP 7.1 or later.
Project status & release process
This library is still under development.
The current releases are numbered 0.x.y. When a non-breaking change is introduced (adding new methods, optimizing existing code, etc.), y is incremented.
When a breaking change is introduced, a new 0.x version cycle is always started.
It is therefore safe to lock your project to a given release cycle, such as 0.1.*.
If you need to upgrade to a newer release cycle, check the release history for a list of changes introduced by each further 0.x.0 version.
Introduction
This library contains a single class, Tag, that represents an HTML tag. You construct a Tag using a tag name:
Attributes
You can pass an optional associative array of attributes to the constructor:
Or you can set attributes later:
Or:
You can also remove attributes:
Content
You can set the content of a Tag, provided that it's not a void tag such as <br>, <input>, etc.
If you try to modify the content of a void tag, you'll get a LogicException.
You can set or append a plain text content:
Or set/append a HTML content:
You can also append another Tag:
You can remove the content of a Tag:
You can check if a Tag has an empty content:
Rendering a tag
You can render a tag by using its render() method, or just by casting it to string:
Encoding
All texts (attributes, content) are expected to be valid UTF-8.