Random Functions Documentation
This file contains a collection of functions for generating random values.
1. randomString
Description: Generate a random string.
Parameters:
length(int): The length of the random string. Default is 10.
Returns:
string: The generated random string.
Usage:
$randomStr = randomString(8);
echo $randomStr; // Example: aB3dE9Gh
2. randomInt
Description: Generate a random integer within a range.
Parameters:
min(int): The minimum value. Default is 0.max(int): The maximum value. Default is 100.
Returns:
int: The random integer.
Usage:
$randomInt = randomInt(1, 10);
echo $randomInt; // Example: 7
3. generatePassword
Description: Generate a random password.
Parameters:
length(int): The length of the password. Default is 8.
Returns:
string: The generated password.
Usage:
$password = generatePassword(12);
echo $password; // Example: 1a2B3c4D5e6F
Example Usage
// Generating a random string
echo randomString(8); // Example output: aB3dE9Gh
// Generating a random integer between 1 and 10
echo randomInt(1, 10); // Example output: 7
// Generating a random password of length 12
echo generatePassword(12); // Example output: 1a2B3c4D5e6F