XG Proyect

StringsHelper
in package

StringsHelper Class

Table of Contents

escapeString()  : string
Replicates the behavior of mysql_real_escape_string
parseReplacements()  : string
Parse a line of text and replace its variables with the provided replacements
randomString()  : string
Generate a random string, using a cryptographically secure pseudorandom number generator (random_int)

Methods

escapeString()

Replicates the behavior of mysql_real_escape_string

public static escapeString(string $value) : string
Parameters
$value : string
Return values
string

parseReplacements()

Parse a line of text and replace its variables with the provided replacements

public static parseReplacements(string $text, array<string|int, mixed> ...$replacements) : string
Parameters
$text : string
$replacements : array<string|int, mixed>
Return values
string

randomString()

Generate a random string, using a cryptographically secure pseudorandom number generator (random_int)

public static randomString(int $length[, string $keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ]) : string

For PHP 7, random_int is a PHP core function For PHP 5.x, depends on https://github.com/paragonie/random_compat

Parameters
$length : int

How many characters do we want?

$keyspace : string = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'

A string of all possible characters to select from

Tags
link
https://stackoverflow.com/questions/6101956/generating-a-random-password-in-php/31284266#31284266
Return values
string

Search results