Welcome to Findnerd.
There are two new functions named random_int and random_bytes which are introduced in PHP7. You can generate the cryptographically secure integers and strings
with these functions. random_int takes two parameters, one is min value and other is maxvalue to be return. It will return the value from assigned range. Please
have a look.
<?php
echo random_int(-22,-4);
echo random_int(344,1233);
?>
It will result any value from -22 to -4 and other will return from 344 to 1233.
random_bytes function will take only one argument that is the length of the bytes to return. Please have a look.
<?php
$bytes = random_bytes(4);
var_dump(bin2hex($bytes));
?>
0 Comment(s)