abstract class Functions (View source)

A class with UTF-8 string functions, some inspired by what might be in some future PHP version.

..

Methods

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 $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 $options = null)

Unicode variant of pathinfo() pathinfo() function is not unicode-friendly if setlocale is not set. It's sufficient to set it to any UTF-8 locale to correctly handle unicode strings.

static mixed
parse_url(string $url, int $component = -1)

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.

Parameters

string $string

The string to convert

Return Value

string

The converted string

static string substr(string $string, int $start, int $length = null)

Unicode variant of substr()

Parameters

string $string

The string to crop

int $start

Position of the left boundary

int $length

(optional) Length of the returned string

Return Value

string

The processed string

static string strtoupper(string $string)

Unicode variant of strtoupper()

Parameters

string $string

The string to uppercase

Return Value

string

The processed string

static string strtolower(string $string)

Unicode variant of strtolower()

Parameters

string $string

The string to lowercase

Return Value

string

The processed string

static int strlen(string $string)

Uniocde variant of strlen() - assumes that the string is a Unicode string, not binary

Parameters

string $string

The string to count the characters of

Return Value

int

The number of characters

static string ucfirst(string $string)

Unicode variant of ucfirst() - assumes that the string is a Unicode string, not binary

Parameters

string $string

The string whose first letter should be uppercased

Return Value

string

The same string, first character uppercased

static string lcfirst(string $string)

Unicode variant of lcfirst() - assumes that the string is a Unicode string, not binary

Parameters

string $string

The string whose first letter should be lowercased

Return Value

string

The same string, first character lowercased

static int strpos(string $haystack, string $needle, int $offset = 0)

Unicode variant of strpos() - assumes that the string is a Unicode string, not binary

Parameters

string $haystack

UTF-8 string to search in

string $needle

UTF-8 string to search for

int $offset

Positition to start the search

Return Value

int

The character position

static string|array pathinfo(string $path, int $options = null)

Unicode variant of pathinfo() pathinfo() function is not unicode-friendly if setlocale is not set. It's sufficient to set it to any UTF-8 locale to correctly handle unicode strings.

This wrapper function temporarily sets locale to 'en_US.UTF-8' and then restores original locale. It's not necessary to use this function in cases, where only file extension is determined, as it's hard to imagine a unicode file extension.

Parameters

string $path
int $options

Optional, one of PATHINFO_DIRNAME, PATHINFO_BASENAME, PATHINFO_EXTENSION or PATHINFO_FILENAME.

Return Value

string|array

See also

http://www.php.net/manual/en/function.pathinfo.php

static mixed parse_url(string $url, int $component = -1)

Parse a URL and return its components, UTF-8 safe

Parameters

string $url

The URL to parse. Invalid characters are replaced by _.

int $component

Specify one of PHP_URL_SCHEME, PHP_URL_HOST, PHP_URL_PORT, PHP_URL_USER, PHP_URL_PASS, PHP_URL_PATH, PHP_URL_QUERY or PHP_URL_FRAGMENT to retrieve just a specific URL component as a string (except when PHP_URL_PORT is given, in which case the return value will be an integer).

Return Value

mixed