\TriTan\CommonEscape

Summary

Methods
Properties
Constants
html()
textarea()
url()
attr()
js()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
htmlSpecialChars()
No private properties found
N/A

Methods

html()

html(string  $string) : string

Escaping for HTML blocks.

Parameters

string $string

Returns

string —

Escaped HTML block.

textarea()

textarea(string  $string) : string

Escaping for textarea.

Parameters

string $string

Returns

string —

Escaped string.

url()

url(string  $url, array  $scheme = array('http', 'https'), boolean  $encode = false) : string

Escaping for url.

Parameters

string $url

The url to be escaped.

array $scheme
boolean $encode

Whether url params should be encoded.

Returns

string —

The escaped $url after the esc_url filter is applied.

attr()

attr(string  $string) : string

Escaping for HTML attributes.

Parameters

string $string

Returns

string —

Escaped HTML attribute.

js()

js(string  $string) : string

Escaping for inline javascript.

Example usage:

 $esc_js = json_encode("Joshua's \"code\"");
 $attribute = $this->js("alert($esc_js);");
 echo '<input type="button" value="push" onclick="'.$attribute.'" />';

Parameters

string $string

Returns

string —

Escaped inline javascript.

htmlSpecialChars()

htmlSpecialChars(string  $string, integer  $flags = ENT_QUOTES | ENT_HTML5, string  $encoding = 'UTF-8', boolean  $double_encoding = true) : string

Convert special characters to HTML entities

Parameters

string $string

The string being converted.

integer $flags

A bitmask of one or more flags.

string $encoding

An optional argument defining the encoding used when converting characters.

boolean $double_encoding

When double_encode is turned off PHP will not encode existing html entities, the default is to convert everything.

Returns

string