PHP 生成任意位数字短信验证码

定义:

class Num {
    public static function getCode($len = 4){
        return substr(strval(rand(0,(10**$len)-1)+10**$len),1,$len);
    }
}

使用:

echo Num::getCode(4);
Last modification:January 30th, 2021 at 06:27 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment