PHP学院的中学生 2019-03-15 14:39:39 267次浏览 1条回复 0 0 0
/**
 * 验证手机验证码
 */
public static function checkPhoneCode($phone, $code)
{
    $result = [
        'state' => 0,
        'msg' => '验证码错误,请重新获取!'
    ];
    $redis = \Yii::$app->redis;
    $params = \Yii::$app->params;
    $smsCode = $redis->get($params['SMS_CODE_PREFIX'] . $phone);
    if (!empty($smsCode) && strcmp($code, $smsCode) == 0) {
        $result['state'] = 1;
        $result['msg'] = '验证码正确!';
    }
    return $result;
}
亿速云
您需要登录后才可以回复。登录 | 立即注册