12345678910111213141516171819202122232425262728293031323334 |
- <?php
- namespace api\models;
- use yii\base\Model;
- use yii\base\InvalidParamException;
- use common\models\User;
- /**
- * Password reset form
- */
- class Common extends Model
- {
- /**
- * 判断价格,保留两位小数
- * @param $str
- * @return int
- */
- static function is_price($str)
- {
- return preg_match('/^([1-9]\d{0,9}|0)([.]?|(\.\d{1,2})?)$/', $str);
- }
- /**
- * 验证手机号码
- * @return bool
- */
- static function is_tel($tel)
- {
- $istel = '/^1[34578][0-9]{9}$/';
- return preg_match($istel, $tel);
- }
- }
|