public function GdprDumpUtilRandom::string in General Data Protection Regulation 7
Generates a random string of ASCII characters of codes 32 to 126.
The generated string includes alpha-numeric characters and common miscellaneous characters. Use this method when testing general input where the content is not restricted.
Parameters
int $length: Length of random string to generate.
Return value
string Randomly generated string.
See also
File
- modules/
gdpr_dump/ src/ GdprDumpUtilRandom.php, line 23
Class
- GdprDumpUtilRandom
- Defines a utility class for creating random data.
Code
public function string($length = 8) {
$str = '';
for ($i = 0; $i < $length; $i++) {
$str .= chr(mt_rand(32, 126));
}
return $str;
}