1.引用Str库
use think\helper\Str;
2.调用方法
use think\\helper\\Str;// 检查字符串中是否包含某些字符串Str::contains($haystack, $needles)// 检查字符串是否以某些字符串结尾Str::endsWith($haystack, $needles)// 获取指定长度的随机字母数字组合的字符串Str::random($length = 16)// 字符串转小写Str::lower($value)// 字符串转大写Str::upper($value)// 获取字符串的长度Str::length($value)// 截取字符串Str::substr($string, $start, $length = null)//驼峰转下划线Str::snake($value, $delimiter='_')//下划线转驼峰(首字母小写)Str::camel($value)//下划线转驼峰(首字母大写)Str::studly//转为首字母大写的标题格式Str::title($value)