BaseEncode
API reference › HTML Helper › Base › BaseEncode
1 subclass
Provides reusable HTML encoding for content and attribute values.
htmlspecialchars() for encoding implementation details.
See also: https://www.php.net/manual/en/function.htmlspecialchars.php.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
content() static | Encodes special characters into HTML entities for use as HTML tag content. | BaseEncode |
value() static | Encodes special characters into HTML entities for use as HTML tag quoted attribute values. | BaseEncode |
Method details
Section titled “Method details”content()
Section titled “content() ”public static function content(string|Stringable $content, bool $doubleEncode = true, string $charset = 'UTF-8'): stringEncodes special characters into HTML entities for use as HTML tag content.
Encodes &, <, and > using ENT_HTML5 | ENT_SUBSTITUTE.
Parameters
| Parameter | Type | Description |
|---|---|---|
$content | string|Stringable | Content to be encoded for safe HTML output. |
$doubleEncode | bool | Whether to encode existing entities (default: true). |
$charset | string | Character encoding to use (default: UTF-8). |
Returns
string: Encoded HTML content safe for tag placement.
See also
value()
Section titled “value() ”public static function value(float|int|string|Stringable|null $value, bool $doubleEncode = true, string $charset = 'UTF-8'): stringEncodes special characters into HTML entities for use as HTML tag quoted attribute values.
Encodes &, <, >, ", and ' using ENT_HTML5 | ENT_SUBSTITUTE | ENT_QUOTES.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | float|Stringable| | Attribute value to be encoded for safe HTML output. |
$doubleEncode | bool | Whether to encode existing entities (default: true). |
$charset | string | Character encoding to use (default: UTF-8). |
Returns
string: Encoded HTML attribute value safe for quoted placement.
See also