Files
OMS/app/dealer/lib/common.php
2025-12-28 23:13:25 +08:00

59 lines
1.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* Copyright © ShopeX http://www.shopex.cn. All rights reserved.
* See LICENSE file for license details.
*/
/**
* 公共共享Lib方法类
*
* @author wangbiao@shopex.cn
* @version 2024.04.08
*/
class dealer_common
{
/**
* 替换特定字符为空
*
* @param string $str
* @return string
*/
public function replaceChar($str)
{
$str = str_replace(array("\r\n","\r","\n","\t","\\","'",'"'," ", ' ','&nbsp;'), '', $str);
return $str;
}
/**
* 检查手机号有效性
*
* @param $mobile
* @param $error_msg
* @return boolean
*/
public function checkMobile($mobile, $error_msg=null)
{
$pattern = "/^\d{8,15}$/i";
$mobile = str_replace(" ", "", $mobile);
if(empty($mobile)) {
$error_msg = '手机号码必需填写';
return false;
}
if (!preg_match($pattern, $mobile)) {
$error_msg = '请输入正确的手机号码';
return false;
}
if ($mobile[0] == '0') {
$error_msg = '手机号码前请不要加0';
return false;
}
return true;
}
}