Download the PHP package oscarotero/html without Composer
On this page you can find all versions of the php package oscarotero/html. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download oscarotero/html
More information about oscarotero/html
Files in oscarotero/html
Package html
Short Description HTML generator
License MIT
Homepage https://github.com/oscarotero/html
Informations about the package html
html
PHP library to generate HTML code
Install
Note, PHP ~7.2 is required
Usage
Attributes
There are two ways to add attributes to the html tags: using an array as the first argument or using magic methods.
All attributes with null
as value are omitted:
Flags
In HTML, flags (or boolean attributes) are attributes that does not need a value. Use boolean
values to add flags.
Example using array syntax:
Example using magic methods:
Classes
Some attributes can contain several space-separated values, for example class
. You can use an array to add classes:
Use the key => value
syntax to add classes under some conditions. Only if the value is evaluated as true, the class will be added:
data-* attributes
Any data-*
attribute containing a non-scalable value, will be converted to json. Unlike flags, boolean values are included too:
Import/Export
Elements implements JsonSerializable
and Serializable
interfaces, so you can export them:
Other interfaces implemented
All elements that can contain children (not self-closing elements like <br>
or <img>
) implement the following standard PHP interfaces:
ArrayAccess
To access to the children elements using the array API.
IteratorAggregate
To iterate with the element:
Countable
To use count()
:
Note that NULL
children are discarded