random_bytes
was introduced with PHP7 (reference).
Alternatively for PHP versions below 7.0
like 5.6
, 5.5
etc, you can use custom function to generate random number using function below.
if( !function_exists('random_bytes') )
{
function random_bytes($length = 6)
{
$characters = '0123456789';
$characters_length = strlen($characters);
$output = '';
for ($i = 0; $i < $length; $i++)
$output .= $characters[rand(0, $characters_length - 1)];
return $output;
}
}