实例演示字符串函数
发布于:2022-05-03 00:19:13
次阅读
md5(),把字符串进行md5加密
//md5()两个参数//1.要计算的字符串//2.可选,true,md5返回16字符长度的2进制,默认false,返回32字符的16进制数echo md5('你好545'), '<br>';echo md5('你好545', true);
$str = "Hello world. (can you hear me?)";echo quotemeta($str);//返回 Hello world\. \(can you hear me\?\)
str_shuffle(),随机打乱字符串
$shuffled = str_shuffle('abcdef');echo $shuffled;
strrev(),反转字符串
echo strrev("Hello world!");
substr_count(),计算字符串出现次数
$text = 'This is a test';echo substr_count($text, 's'); // 3echo substr_count($text, 's', 5); // 2,从第6个开始计算,只有两个s
ucfirst(),将字符串首字母转换成大写
$foo = ucfirst('hello world!');echo $foo;