Skip to content
docsv0.1.0

Html

HTML-escaping helpers shared by every renderer and the template engine in this package: safe attribute-string assembly and a single escaping primitive both are built on.

Html::attrs()

public static function attrs(array $attributes): string

Renders `$attributes` as a space-joined, HTML-escaped attribute string. A `null` or `false` value omits the attribute entirely; `true` emits the bare attribute name (a boolean HTML attribute, e.g. `required`); any other value is escaped and quoted.

Parameters

Parameters of attrs()
NameTypeDescription
$attributesarray<string, (string | null | bool | int | float)>

Html::escape()

public static function escape(string $value): string

HTML-escapes `$value` for safe interpolation into markup: quotes, ampersands, and angle brackets are all escaped (`ENT_QUOTES`), and an invalid UTF-8 byte sequence is substituted rather than aborting (`ENT_SUBSTITUTE`).

Parameters

Parameters of escape()
NameTypeDescription
$valuestring