| 123456789101112131415161718192021222324252627282930 |
- <?php
- namespace App\Services\Api;
- class CommonService
- {
- /**
- * 验证邮箱是否正确
- * @param INT $email
- */
- public static function is_email($email) {
- if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
- return false;
- }
- return true;
- }
- /**
- * 验证手机号是否正确
- * @param INT $mobile
- */
- public static function is_mobile($mobile) {
- if (!is_numeric($mobile)) {
- return false;
- }
- return preg_match('#^13[\d]{9}$|^14[5,7]{1}\d{8}$|^15[^4]{1}\d{8}$|^17[0,6,7,8]{1}\d{8}$|^18[\d]{9}$#', $mobile) ? true : false;
- }
- }
|