// $min and $max are optional rand($min,$max);
echo random_int(0,50);
$limit = 3; echo random_int(10 ** ($limit - 1), (10 ** $limit) - 1);