make_rand_str()

function make_rand_str(int $length = 32, bool $uppercase = false): string

Description

Generates a cryptographically secure random string of alphanumeric characters. This is useful for generating tokens, passwords, API keys, and other identifiers.

Parameters

Parameter Type Description Default
$length int The length of the random string to generate. 32
$uppercase bool Whether to include uppercase characters in the generated string. false

Return Value

Type Description
string The randomly generated alphanumeric string.

Example Usage