Functions
abstract class Functions (View source)
A class with UTF-8 string functions, some inspired by what might be in some future PHP version.
..
Methods
Converts the first character of each word to uppercase and all remaining characters to lowercase.
Unicode variant of substr()
Unicode variant of strtoupper()
Unicode variant of strtolower()
Uniocde variant of strlen() - assumes that the string is a Unicode string, not binary
Unicode variant of ucfirst() - assumes that the string is a Unicode string, not binary
Unicode variant of lcfirst() - assumes that the string is a Unicode string, not binary
Unicode variant of strpos() - assumes that the string is a Unicode string, not binary
Unicode variant of pathinfo()
Parse a URL and return its components, UTF-8 safe
Details
static string
strtotitle(string $string)
Converts the first character of each word to uppercase and all remaining characters to lowercase.
static string
substr(string $string, int $start, int|null $length = null)
Unicode variant of substr()
static string
strtoupper(string $string)
Unicode variant of strtoupper()
static string
strtolower(string $string)
Unicode variant of strtolower()
static int
strlen(string $string)
Uniocde variant of strlen() - assumes that the string is a Unicode string, not binary
static string
ucfirst(string $string)
Unicode variant of ucfirst() - assumes that the string is a Unicode string, not binary
static string
lcfirst(string $string)
Unicode variant of lcfirst() - assumes that the string is a Unicode string, not binary
static int
strpos(string $haystack, string $needle, int $offset = 0)
Unicode variant of strpos() - assumes that the string is a Unicode string, not binary
static string|array
pathinfo(string $path, int|null $options = null)
Unicode variant of pathinfo()
Kept for backwards compatibility only — it delegates to the native function. pathinfo() is UTF-8 safe on its own: the only characters it splits on, '/' and '.', cannot occur inside a multi-byte UTF-8 sequence, and PHP no longer classifies path bytes through LC_CTYPE. Verified identical output under the C, ISO8859-1, SJIS and UTF-8 locales.
This used to switch LC_CTYPE to 'en_US.UTF-8' for the duration of the call. That was both unnecessary and harmful: restoring the locale string afterwards does not restore PCRE's character tables, so from the first call onwards every regex without the /u modifier changed meaning process-wide — \w started matching bytes >= 0x80.
static mixed
parse_url(string $url, int $component = -1)
Parse a URL and return its components, UTF-8 safe