判断是否是正整数
if (!preg_match("/^[1-9][0-9]*$/" ,$data['service_month'])) {
return ['statusCode'=>300,'message'=>'操作失败,服务期限只能是正整数!'];
}
向下取整
floor(3.5); // 3
floor(-3.5);// -4
四舍五入
round(3.567,2);// 3.57
随机数
// php7才用,密码安全
random_int(int $min, int $max) : int // 随机数
// php5就可以用,非密码安全的
mt_rand(int $min, int $max) : int // 比rand速度快点
rand(int $min, int $max) : int // 不推荐