RdbAdmin Module

RdbaString
in package

String class. (String class name is reserved, see https://www.php.net/manual/en/reserved.other-reserved-words.php for more details.)

Tags
since
0.1

Table of Contents

Methods

__callStatic()  : mixed
For static methods on non-static methods.
filterSanitizeString()  : string
Strip HTML tags and then do the `htmlspecialchars()` with single quotes.
random()  : string
Generate random string.
randomUnicode()  : string
Generate random unicode string.
sanitizeDisplayname()  : string
Sanitize display name.
sanitizeUsername()  : string
Sanitize username.
staticFilterSanitizeString()  : static
staticRandom()  : static
staticRandomUnicode()  : static
staticSanitizeDisplayname()  : static
staticSanitizeUsername()  : static

Methods

__callStatic()

For static methods on non-static methods.

public static __callStatic(string $name, array<string|int, mixed> $arguments) : mixed
Parameters
$name : string

The method name.

$arguments : array<string|int, mixed>

The method's arguments.

Tags
since
1.2.10

filterSanitizeString()

Strip HTML tags and then do the `htmlspecialchars()` with single quotes.

public filterSanitizeString(string $string) : string

This is for replacement that FILTER_SANITIZE_STRING constant has been deprecated since PHP 8.1
This method does not support any flags that FILTER_SANITIZE_STRING constant may have.

Parameters
$string : string

The string to be filter and sanitize.

Tags
since
1.2.10
Return values
string

Return filtered and sanitized string.

random()

Generate random string.

public random([int $length = 10 ][, string $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ]) : string

For ASCII text only.

Parameters
$length : int = 10

String length.

$characters : string = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'

The allowed characters.

Tags
link

Reference

link

PHP string bracket reference.

Return values
string

Return generated random string.

randomUnicode()

Generate random unicode string.

public randomUnicode([int $length = 10 ][, string $characters = '' ]) : string

To count the length, please use mb_strlen() instead of strlen().

Parameters
$length : int = 10

String length.

$characters : string = ''

The allowed characters.

Tags
link

Reference

Return values
string

Return generated random string.

sanitizeDisplayname()

Sanitize display name.

public sanitizeDisplayname(string $displayname) : string

The difference from sanitizeUsername() as it will not remove space between text but allowed just one.

Parameters
$displayname : string

The display name.

Tags
link

Reference for some disallowed characters.

Return values
string

Return sanitized display name.

staticFilterSanitizeString()

public staticFilterSanitizeString([string $paramName = ]) : static
Parameters
$paramName : string =
Return values
static

staticRandom()

public staticRandom([int $length = ][, string $characters = ]) : static
Parameters
$length : int =
$characters : string =
Return values
static

staticRandomUnicode()

public staticRandomUnicode([int $length = ][, string $characters = ]) : static
Parameters
$length : int =
$characters : string =
Return values
static

staticSanitizeDisplayname()

public staticSanitizeDisplayname([string $displayname = ]) : static
Parameters
$displayname : string =
Return values
static

staticSanitizeUsername()

public staticSanitizeUsername([string $username = ]) : static
Parameters
$username : string =
Return values
static

        
On this page

Search results