StrHelper
class StrHelper
字串处理
Methods
获取 markdown 索引
获取文件名后缀名
获取中杠线分割的单词
获取文件名前缀
检测是否含有空格符
取消转义
转义操作
转义特殊字符
能做到代码不危害大众, 但是还不能把代码安全展示出来
删除代码中的换行符
去除空格, 换行
截取字符串
文字 -> 16进制表示
16进制转换为字串
返回随机字串, 区分大小写
随机ASCII字符
获取一定范围内的随机数字 位数不足补零
转换字符
批量转换
中文->Utf8
计算字符长度
检测字符是否为UTF8编码
菊花文生成
JS 转义函数
分割 separate, 去除空格
解析 a|1;b|2 样式的字串到数组
sql against encode
reverse for match
隐藏联系方式
隐藏邮箱
Converts number to its ordinal English form.
Converts line breaks to a standard \r\n pattern.
Removes the starting slash from a class namespace \
从对象或者类名中生成 class id
返回一个类的命名空间
清除链接
完善链接
将内容截取到介绍中
格式化ID
返回唯一的值
Details
at line 20
array
mdToc(string $content)
获取 markdown 索引
at line 73
static string
suffix(string $string, string $split = '.')
获取文件名后缀名
at line 83
static array|string|string[]
slug(string $string)
获取中杠线分割的单词
at line 94
static string
prefix(string $string, string $split = '.')
获取文件名前缀
at line 104
static int
hasSpace(string $value)
检测是否含有空格符
at line 114
static array|string
stripSlashes(mixed $input)
取消转义
at line 124
static array|string
addSlashes(mixed $input)
转义操作
at line 135
static array|mixed|string
htmlSpecialChars(mixed $input, bool $preserveAmpersand = true)
转义特殊字符
at line 160
static array|mixed
safe(mixed $input)
能做到代码不危害大众, 但是还不能把代码安全展示出来
at line 187
static mixed
trimEOL(string $string, bool $js = false)
删除代码中的换行符
at line 199
static string
trimSpace(string $string)
去除空格, 换行
at line 215
static mixed|string
cut(string $string, int $length, string $suffix = '', int $start = 0, string $char_code = 'utf-8')
截取字符串
at line 283
static string
toHex(string $str)
文字 -> 16进制表示
at line 293
static string
fromHex(string $hex)
16进制转换为字串
at line 313
static string
randomCustom(int $length, string $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz')
返回随机字串, 区分大小写
at line 329
static string
randomAscii(int $length = 8)
随机ASCII字符
at line 345
static string
randomNumber(int $min, int $max)
获取一定范围内的随机数字 位数不足补零
at line 357
static array|string
convert(string $str, string $fromCharset = 'utf-8', string $toCharset = 'gbk')
转换字符
at line 405
static array
batchConvert(mixed $str, string $fromCharset = 'utf-8', string $toCharset = 'gbk')
批量转换
at line 426
static string
ch2Utf8(string $char)
中文->Utf8
at line 456
static int
count(mixed $string)
计算字符长度
at line 475
static int
isUtf8(string $str)
检测字符是否为UTF8编码
at line 494
static string
chrysanthemum(string $str)
菊花文生成
at line 516
static string
jsEscape(string $str)
JS 转义函数
at line 527
static array
separate(string $separator, string $str)
分割 separate, 去除空格
at line 549
static mixed
parseKey(mixed $str)
解析 a|1;b|2 样式的字串到数组
at line 582
static string
matchEncode(mixed $ids)
sql against encode
at line 597
static array|mixed
matchDecode(mixed $ids, bool|false $array = false)
reverse for match
at line 620
static string
hideContact(string $input, int $start = 3, int $end = -4, string $replace = '****')
隐藏联系方式
at line 633
static string
hideEmail(string $input)
隐藏邮箱
at line 649
static string
ordinal(int $number)
Converts number to its ordinal English form.
This method converts 13 to 13th, 2 to 2nd ...
at line 672
static mixed
normalizeEol(string $string)
Converts line breaks to a standard \r\n pattern.
at line 682
static string
normalizeClassName(mixed $name)
Removes the starting slash from a class namespace \
at line 698
static string
getClassId(mixed $name)
从对象或者类名中生成 class id
at line 714
static bool|string
getClassNamespace(string $name)
返回一个类的命名空间
at line 726
static mixed
clearLink(string $content)
清除链接
at line 738
static string
fixLink(string $url)
完善链接
at line 751
static mixed|string
intro(string $content, int $length = 0)
将内容截取到介绍中
at line 770
static string|string[]
formatId(string|string[] $string)
格式化ID
at line 783
static mixed
unique(string $current, string $str, string $delimiter = ',', bool $remove = false)
返回唯一的值