HtmLawed
in package
Table of Contents
Methods
- hl() : mixed
- hl_attributeValue() : mixed
- Validate attribute value and possibly reset to a default.
- hl_balance() : mixed
- hl_commentCdata() : string
- Handle comment/CDATA section.
- hl_deprecatedElement() : mixed
- Transform deprecated element, with any attribute, into a new element.
- hl_entity() : string
- Handle entity.
- hl_regex() : int
- Check regex pattern for PHP error.
- hl_spec() : array<string|int, mixed>
- Parse $spec htmLawed argument as array.
- hl_tag() : string
- Handle tag text with </> limiters, and attributes in opening tags.
- hl_tidy() : mixed
- Tidy/beautify HTM by adding newline and other spaces (padding), or compact by removing unnecessary spaces.
- hl_url() : string
- Handle URL to convert to relative/absolute type, block scheme, or add anti-spam text.
- hl_version() : string
- Report version.
Methods
hl()
public
static hl(mixed $t[, mixed $C = 1 ][, mixed $S = array() ]) : mixed
Parameters
- $t : mixed
- $C : mixed = 1
- $S : mixed = array()
hl_attributeValue()
Validate attribute value and possibly reset to a default.
public
static hl_attributeValue(string $attr, string $value, array<string|int, mixed> $ruleAr, string $ele) : mixed
Parameters
- $attr : string
-
Attribute name.
- $value : string
-
Attribute value.
- $ruleAr : array<string|int, mixed>
-
Array of rules derived from $spec.
- $ele : string
-
Element.
Return values
mixed —0 if invalid $value, or string with validated or default value.
hl_balance()
public
static hl_balance(mixed $t[, mixed $act = 1 ][, mixed $parentEle = 'div' ]) : mixed
Parameters
- $t : mixed
- $act : mixed = 1
- $parentEle : mixed = 'div'
hl_commentCdata()
Handle comment/CDATA section.
public
static hl_commentCdata(array<string|int, mixed> $t) : string
Filter/sanitize as per $config and disguise special characters.
Parameters
- $t : array<string|int, mixed>
-
Array result of preg_replace, with potential comment/CDATA.
Return values
string —Sanitized comment/CDATA with hidden special characters.
hl_deprecatedElement()
Transform deprecated element, with any attribute, into a new element.
public
static hl_deprecatedElement(string &$ele, string &$attrStr[, int $act = 1 ]) : mixed
Parameters
- $ele : string
-
Deprecated element.
- $attrStr : string
-
Attribute string of element.
- $act : int = 1
-
No transformation if 2.
Return values
mixed —New attribute string (may be empty) or 0.
hl_entity()
Handle entity.
public
static hl_entity(array<string|int, mixed> $t) : string
As needed, convert to named/hexadecimal form, or neutralize '&' as '&'.
Parameters
- $t : array<string|int, mixed>
-
Array result of preg_replace, with potential entity.
Return values
string —Neutralized or converted entity.
hl_regex()
Check regex pattern for PHP error.
public
static hl_regex(string $t) : int
Parameters
- $t : string
-
Pattern including limiters/modifiers.
Return values
int —0 or 1 if pattern is invalid or valid, respectively.
hl_spec()
Parse $spec htmLawed argument as array.
public
static hl_spec(string $t) : array<string|int, mixed>
Parameters
- $t : string
-
Value of $spec.
Return values
array<string|int, mixed> —Multidimensional array of form: tag -> attribute -> rule.
hl_tag()
Handle tag text with </> limiters, and attributes in opening tags.
public
static hl_tag(array<string|int, mixed> $t) : string
Parameters
- $t : array<string|int, mixed>
-
Array from preg_replace call.
Return values
string —Tag with any attribute, or text with </> neutralized into entities, or empty.
hl_tidy()
Tidy/beautify HTM by adding newline and other spaces (padding), or compact by removing unnecessary spaces.
public
static hl_tidy(string $t, mixed $format, string $parentEle) : mixed
Parameters
- $t : string
-
HTM.
- $format : mixed
-
-1 (compact) or string (type of padding).
- $parentEle : string
-
Parent element of $t.
Return values
mixed —Transformed attribute string (may be empty) or 0.
hl_url()
Handle URL to convert to relative/absolute type, block scheme, or add anti-spam text.
public
static hl_url(mixed $url[, mixed $attr = null ]) : string
Parameters
- $url : mixed
-
URL string, or array with URL value (if $attr is null).
- $attr : mixed = null
-
Attribute name string, or null (if $url is array).
Return values
string —With URL after any conversion/obfuscation.
hl_version()
Report version.
public
static hl_version() : string
Return values
string —Version.