Enc
in package
Encoding of data for various outputs
Table of Contents
Methods
- cleanfunky() : string
- Strip funky stuff from a string.
- html() : string
- Encoding for HTML Existing HTML entities in a string will be double-encoded
- htmlNoDup() : string
- Encoding for HTML, but safe from double-encoding of existing entities
- httpfield() : mixed
- Encoding for field name in a form element
- id() : mixed
- Encoding for ID or CLASS attributes
- js() : mixed
- Encoding for going inside a JS string
- jsdate() : string|null
- Returns the JS code needed to initialise a Date() object with the specified date.
- url() : mixed
- Encoding for a part of a URL (i.e. GET parameter value
- urlname() : string
- Nice name of something when dealing with friendly URLs.
- xml() : mixed
- Encoding for XML
Methods
cleanfunky()
Strip funky stuff from a string.
public
static cleanfunky(mixed $value) : string
Funky stuff is anything in the ASCII control plane (0x00 - 0x1F) Except tab, line feed, carriage return
Parameters
- $value : mixed
Return values
stringhtml()
Encoding for HTML Existing HTML entities in a string will be double-encoded
public
static html(string|int|float|bool $value) : string
Parameters
- $value : string|int|float|bool
-
The text to encode. This should be plain (i.e. non-HTML) text
Tags
Return values
stringhtmlNoDup()
Encoding for HTML, but safe from double-encoding of existing entities
public
static htmlNoDup(string|int|float|bool $value) : string
Parameters
- $value : string|int|float|bool
-
The text to encode. This should be plain (i.e. non-HTML) text
Tags
Return values
stringhttpfield()
Encoding for field name in a form element
public
static httpfield(string $value) : mixed
Parameters
- $value : string
-
The value to encode
id()
Encoding for ID or CLASS attributes
public
static id(string $value) : mixed
Parameters
- $value : string
-
The value to encode
js()
Encoding for going inside a JS string
public
static js(string $value) : mixed
Parameters
- $value : string
-
The value to encode
jsdate()
Returns the JS code needed to initialise a Date() object with the specified date.
public
static jsdate(string|array<string|int, mixed> $value[, string $from = 'mysql' ]) : string|null
This should only be used for dates. For times or date-times, use a different function.
From types:
'mysql' - a mysql-formatted date in the form YYYY-MM-DD
'array' - an array [
Parameters
- $value : string|array<string|int, mixed>
-
The value to convert.
- $from : string = 'mysql'
-
What format the date was in origanally.
Return values
string|null —JavaScript snippet for the given date or NULL if the input value is invalid
url()
Encoding for a part of a URL (i.e. GET parameter value
public
static url(string $value) : mixed
Parameters
- $value : string
-
The value to encode
urlname()
Nice name of something when dealing with friendly URLs.
public
static urlname(string $value[, mixed $delimiter = '-' ]) : string
This provides the backend for Slug::create
Parameters
- $value : string
-
The value to encode
- $delimiter : mixed = '-'
Return values
stringxml()
Encoding for XML
public
static xml(string $value) : mixed
Parameters
- $value : string
-
The value to encode