Skip to content
PHP Ecosystem
Explore

BaseEncode

API reference › HTML Helper › Base › BaseEncode

abstract classUIAwesome\Html\Helper\Base\BaseEncode
Sourcesrc/Base/BaseEncode.php
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.

MethodDescriptionDefined by
content() staticEncodes special characters into HTML entities for use as HTML tag content.BaseEncode
value() staticEncodes special characters into HTML entities for use as HTML tag quoted attribute values.BaseEncode
public static function content(string|Stringable $content, bool $doubleEncode = true, string $charset = 'UTF-8'): string

Encodes special characters into HTML entities for use as HTML tag content.

Encodes &, <, and > using ENT_HTML5 | ENT_SUBSTITUTE.

Parameters

ParameterTypeDescription
$contentstring|StringableContent to be encoded for safe HTML output.
$doubleEncodeboolWhether to encode existing entities (default: true).
$charsetstringCharacter encoding to use (default: UTF-8).

Returns

string: Encoded HTML content safe for tag placement.

See also

public static function value(float|int|string|Stringable|null $value, bool $doubleEncode = true, string $charset = 'UTF-8'): string

Encodes special characters into HTML entities for use as HTML tag quoted attribute values.

Encodes &, <, >, ", and ' using ENT_HTML5 | ENT_SUBSTITUTE | ENT_QUOTES.

Parameters

ParameterTypeDescription
$valuefloat|int|string|Stringable|nullAttribute value to be encoded for safe HTML output.
$doubleEncodeboolWhether to encode existing entities (default: true).
$charsetstringCharacter encoding to use (default: UTF-8).

Returns

string: Encoded HTML attribute value safe for quoted placement.

See also