class StringUtil (View source)

Various PHP string related utility functions.

Methods

static boolean
endsWith(string $input, string $suffix)

Return true if the first paramater contains the second parameter at the end.

static boolean
startsWith(string $input, string $prefix)

Return true if the input string starts with the prefix string.

static string
base64UrlEncode(string $input)

Base64 encode a string, ensuring that the output is safe to use in a URL.

static string
base64UrlDecode(string $input)

Base64 decode a string that was encoded with base64UrlEncode.

Details

static boolean endsWith(string $input, string $suffix)

Return true if the first paramater contains the second parameter at the end.

Parameters

string $input The input string which may contain the suffix.
string $suffix The string to look for at the end of the input.

Return Value

boolean true iff the input contains the suffix at the end.

static boolean startsWith(string $input, string $prefix)

Return true if the input string starts with the prefix string.

Parameters

string $input The string which may contain the prefix at the start.
string $prefix The string to look for at the start of the input.

Return Value

boolean true iff the input contains the prefix at the start.

static string base64UrlEncode(string $input)

Base64 encode a string, ensuring that the output is safe to use in a URL.

Parameters

string $input The string which may not be url safe.

Return Value

string A Base64 encoded url safe string.

static string base64UrlDecode(string $input)

Base64 decode a string that was encoded with base64UrlEncode.

Parameters

string $input The url safe Base64 encoded string.

Return Value

string The original string which may not be url safe.