工具类
use Phpbe\Util\Validator;
// 是否是合法的手机号码
if (!Validator::isMobile('18812341234')) {
throw new \Exception('手机号码不会法!');
}
// 是否是合法的邮箱
if (!Validator::isEmail('i@liu12.com')) {
throw new \Exception('邮箱不会法!');
}
// 是否是合法的IP
if (!Validator::isIp('192.168.0.1')) {
throw new \Exception('IP不会法!');
}
// 是否是合法的域名
if (!Validator::isDomain('www.baidu.com')) {
throw new \Exception('域名不会法!');
}
// 是否是合法的网址
if (!Validator::isUrl('http://www.baidu.com')) {
throw new \Exception('网址不会法!');
}