StringHelper
Tags
Table of Contents
Constants
- UTF8_REGEXP = '/(?: [\x09\x0A\x0D\x20-\x7E] # ASCII | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 )+/xs'
Methods
- changeCaseToLower() : string
- Special version of strtolower.
- changeCaseToUpper() : string
- Special version of strtoupper.
- escapePhp() : string
- Escapes symbols of "'$ in given string.
- getLength() : int
- Special version of strlen.
- getPosition() : bool|int
- Special version of strpos.
- getSubstring() : string
- Special version of substr.
- hasPhpTokens() : bool
- Validate phrase for php tokens.
- htmlSpecialChars() : string
- Convert special characters to HTML entities.
- unescapePhp() : string
- Removes escape symbols in given string.
- validateUtf8OctetSequences() : bool
- Validates UTF-8 octet sequences: 0xxxxxxx 110xxxxx 10xxxxxx 1110xxxx 10xxxxxx 10xxxxxx 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
Constants
UTF8_REGEXP
public
mixed
UTF8_REGEXP
= '/(?:
[\x09\x0A\x0D\x20-\x7E] # ASCII
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
| \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
| \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
)+/xs'
Methods
changeCaseToLower()
Special version of strtolower.
public
static changeCaseToLower(string $str) : string
Parameters
- $str : string
-
String to convert.
Return values
stringchangeCaseToUpper()
Special version of strtoupper.
public
static changeCaseToUpper(string $str) : string
Parameters
- $str : string
-
String to convert.
Return values
stringescapePhp()
Escapes symbols of "'$ in given string.
public
static escapePhp(string $str[, string $enclosure = '"' ][, string $additional = '' ]) : string
Parameters
- $str : string
-
String to escape.
- $enclosure : string = '"'
-
Enclosure symbol " or ' and <<< for heredoc syntax.
- $additional : string = ''
-
Additional symbols to escape.
Return values
stringgetLength()
Special version of strlen.
public
static getLength(string $str[, string $encoding = null ]) : int
Parameters
- $str : string
-
String to measure.
- $encoding : string = null
-
Defines encoding used in conversion.
Return values
intgetPosition()
Special version of strpos.
public
static getPosition(string $haystack, string $needle[, int $offset = 0 ][, string $encoding = null ]) : bool|int
Parameters
- $haystack : string
-
String to analyze.
- $needle : string
-
String to find.
- $offset : int = 0
-
The search offset.
- $encoding : string = null
-
Defines encoding used in conversion.
Return values
bool|intgetSubstring()
Special version of substr.
public
static getSubstring(string $str, int $start, int $length[, string $encoding = null ]) : string
Parameters
- $str : string
-
String to convert.
- $start : int
-
Starting position.
- $length : int
-
Count characters to extract.
- $encoding : string = null
-
Defines encoding used in conversion.
Return values
stringhasPhpTokens()
Validate phrase for php tokens.
public
static hasPhpTokens(string $str[, string $enclosure = '"' ]) : bool
Parameters
- $str : string
- $enclosure : string = '"'
Return values
boolhtmlSpecialChars()
Convert special characters to HTML entities.
public
static htmlSpecialChars(string $string[, int $flags = ENT_COMPAT ][, string $encoding = null ]) : string
Parameters
- $string : string
-
The string being converted.
- $flags : int = ENT_COMPAT
-
A bitmask mask which specify how to handle quotes.
- $encoding : string = null
-
Defines encoding used in conversion.
Return values
stringunescapePhp()
Removes escape symbols in given string.
public
static unescapePhp(string $str[, string $enclosure = '"' ]) : string
Parameters
- $str : string
-
String to unescape.
- $enclosure : string = '"'
-
Enclosure symbol " or '.
Return values
stringvalidateUtf8OctetSequences()
Validates UTF-8 octet sequences: 0xxxxxxx 110xxxxx 10xxxxxx 1110xxxx 10xxxxxx 10xxxxxx 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
public
static validateUtf8OctetSequences(string $string) : bool
Parameters
- $string : string