class UtilHelper

功能函数类

Methods

array
squarePoint(float $lng, float $lat, float $distance = 0.5)

计算某个经纬度的周围某段距离的正方形的四个点

static bool
isEmail(string $email)

检测是否email

static bool
isUrl(string $url)

是不是url地址

static bool
isUsername(string $username, bool $is_sub = false)

是否是用户名, 子用户比主用户多一个英文版本的 :

static bool
isRobot()

检测是否搜索机器人.

static bool
isIp(string $ip)

检测IP的匹配

static bool
isLocalIp(string $ip)

是否是局域网IP

static bool
isMd5(string $str)

是否是md5, 检测是否32位数字字母的组合

static bool
isImage(string $filename)

文件是否是图像

static bool
isMobile(string $mobile)

是否是正确的手机号码

static bool
isChMobile(string $mobile)

是否是国内手机号

static bool
isTelephone(string $telephone)

联系方式

static bool
isChinese(string $str)

是否全部为中文, 并且验证长度

static bool
hasChinese(string $str)

是否存在汉字

static bool
isChId(string $id_card)

验证身份证号 , 身份证有效性检测

static bool
isBankNumber(string $bank_account)

是否是标准的银行账号 // todo

static bool
hasSpace(string $value)

检测是否含有空格符

static bool
isWord(string $letter)

是否是单词, 不包含空格, 仅仅是字母组合

static bool
hasTag(string $content)

检测代码中是否含有 html 标签

static float|string
formatDecimal(string $input, bool $sprinft = true, int $precision = 2)

格式化小数, 也可以用于货币的格式化

static string
fixLink(string $url, bool $is_https = false)

修复链接地址, 如果没有 :// 则补齐

static bool
chidChecksum18(string $idcard)

18位身份证校验码有效性检查

static string
md5(string|array $str)

计算给定 字串/数组 的 md5 的值, 支持多个参数传入

static array
genTree(array|object $items, string $id = 'id', string $pid = 'pid', string $son = 'children', $reserve_pid = true)

生成递归数列

static array
objToArray(object|array $obj)

对象到数组

static array
genSplash(string $type = 'success', string $message = '', string|array $append = '') deprecated

生成 提示信息, 当前已经不使用字符串来生成提示信息

static bool|string
sqlTime(int $time = null) deprecated

返回 sql 中存储的时间信息

static array
kvToIdTitle(array $kv)

Kv 转化成Id/Title 类型

static int
toHour(int $hour, int $day = 0)

转换成小时

static string
formatBytes(int $bytes, int $precision = 2)

格式化文件大小

static int
sizeToBytes(string $size)

可识别的大小转换为 bytes

static bool
isVersion(string $version)

检测是不是正规版本号

static string
getDistance(float $lng1, float $lat1, float $lng2, float $lat2)

根据两点间的经纬度计算距离

static string
guid()

guid 生成函数

static bool
isJson(mixed $string)

检测是否是有效的json数据格式

static bool
isDate(string $string)

检测是否是有效的日期格式

static bool
isPwd(string $pwd)

是否是密码

static bool
isComma(string $str)

是否是逗号隔开的数字字符串

Details

at line 23
array squarePoint(float $lng, float $lat, float $distance = 0.5)

计算某个经纬度的周围某段距离的正方形的四个点

Parameters

float $lng 经度
float $lat 纬度
float $distance 该点所在圆的半径,该圆与此正方形内切,默认值为0.5千米

Return Value

array 正方形的四个点的经纬度坐标

at line 48
static bool isEmail(string $email)

检测是否email

Parameters

string $email

Email address

Return Value

bool

at line 58
static bool isUrl(string $url)

是不是url地址

Parameters

string $url

url address

Return Value

bool

at line 71
static bool isUsername(string $username, bool $is_sub = false)

是否是用户名, 子用户比主用户多一个英文版本的 :

Parameters

string $username 用户名
bool $is_sub 是否是子用户

Return Value

bool

at line 83
static bool isRobot()

检测是否搜索机器人.

Return Value

bool

at line 101
static bool isIp(string $ip)

检测IP的匹配

Parameters

string $ip 是否是IPv4

Return Value

bool

at line 112
static bool isLocalIp(string $ip)

是否是局域网IP

Parameters

string $ip

Return Value

bool

at line 125
static bool isMd5(string $str)

是否是md5, 检测是否32位数字字母的组合

Parameters

string $str string

Return Value

bool

at line 135
static bool isImage(string $filename)

文件是否是图像

Parameters

string $filename 文件名是否是图像

Return Value

bool

at line 146
static bool isMobile(string $mobile)

是否是正确的手机号码

Parameters

string $mobile 手机号

Return Value

bool

at line 159
static bool isChMobile(string $mobile)

是否是国内手机号

Parameters

string $mobile

Return Value

bool

at line 169
static bool isTelephone(string $telephone)

联系方式

Parameters

string $telephone 电话号码

Return Value

bool

at line 181
static bool isChinese(string $str)

是否全部为中文, 并且验证长度

Parameters

string $str 字串

Return Value

bool

at line 192
static bool hasChinese(string $str)

是否存在汉字

Parameters

string $str 字符串

Return Value

bool

at line 202
static bool isChId(string $id_card)

验证身份证号 , 身份证有效性检测

Parameters

string $id_card 身份证号码

Return Value

bool

at line 223
static bool isBankNumber(string $bank_account)

是否是标准的银行账号 // todo

Parameters

string $bank_account 银行账号

Return Value

bool

at line 235
static bool hasSpace(string $value)

检测是否含有空格符

Parameters

string $value 需要检测的字串

Return Value

bool

at line 245
static bool isWord(string $letter)

是否是单词, 不包含空格, 仅仅是字母组合

Parameters

string $letter 检测是否单词

Return Value

bool

at line 256
static bool hasTag(string $content)

检测代码中是否含有 html 标签

Parameters

string $content string

Return Value

bool

at line 268
static float|string formatDecimal(string $input, bool $sprinft = true, int $precision = 2)

格式化小数, 也可以用于货币的格式化

Parameters

string $input value
bool $sprinft 是否格式化
int $precision 保留小数

Return Value

float|string

修复链接地址, 如果没有 :// 则补齐

Parameters

string $url string
bool $is_https

Return Value

string

at line 298
static bool chidChecksum18(string $idcard)

18位身份证校验码有效性检查

Parameters

string $idcard

18 位身份证号码

Return Value

bool

at line 312
static string md5(string|array $str)

计算给定 字串/数组 的 md5 的值, 支持多个参数传入

Parameters

string|array $str

need md5 string

Return Value

string

at line 330
static array genTree(array|object $items, string $id = 'id', string $pid = 'pid', string $son = 'children', $reserve_pid = true)

生成递归数列

Parameters

array|object $items 条目
string $id id键
string $pid 父级元素
string $son 子元素
$reserve_pid

Return Value

array 返回的排序好的数组

at line 369
static array objToArray(object|array $obj)

对象到数组

Parameters

object|array $obj 需要转换的对象

Return Value

array

at line 394
static array genSplash(string $type = 'success', string $message = '', string|array $append = '') deprecated

deprecated 4.2

生成 提示信息, 当前已经不使用字符串来生成提示信息

Parameters

string $type type
string $message message
string|array $append append

Return Value

array

at line 426
static bool|string sqlTime(int $time = null) deprecated

deprecated 4.2

返回 sql 中存储的时间信息

Parameters

int $time time

Return Value

bool|string

See also

Carbon

at line 440
static array kvToIdTitle(array $kv)

Kv 转化成Id/Title 类型

Parameters

array $kv

Return Value

array

at line 456
static int toHour(int $hour, int $day = 0)

转换成小时

Parameters

int $hour hour
int $day

day num

Return Value

int

at line 467
static string formatBytes(int $bytes, int $precision = 2)

格式化文件大小

Parameters

int $bytes 长度
int $precision 分数

Return Value

string

at line 487
static int sizeToBytes(string $size)

可识别的大小转换为 bytes

Parameters

string $size

Return Value

int

at line 506
static bool isVersion(string $version)

检测是不是正规版本号

Parameters

string $version 版本

Return Value

bool

at line 519
static string getDistance(float $lng1, float $lat1, float $lng2, float $lat2)

根据两点间的经纬度计算距离

Parameters

float $lng1 lng1
float $lat1 lat1
float $lng2 lng2
float $lat2 lat2

Return Value

string

at line 537
static string guid()

guid 生成函数

Return Value

string

at line 557
static bool isJson(mixed $string)

检测是否是有效的json数据格式

Parameters

mixed $string string

Return Value

bool

at line 572
static bool isDate(string $string)

检测是否是有效的日期格式

Parameters

string $string string

Return Value

bool

at line 586
static bool isPwd(string $pwd)

是否是密码

Parameters

string $pwd pwd

Return Value

bool

at line 599
static bool isComma(string $str)

是否是逗号隔开的数字字符串

Parameters

string $str str

Return Value

bool