<?php/** * Created by 郭鹏. * User: msi * Date: 2017/9/27 * Time: 14:17 */ //随机数生成器echo rand();echo "<br>";//生成某个范围随机数echo rand(0,10);echo "<br>";//获取当前时间戳echo time();echo "<br>";//格式化显示时间echo "<br>";echo date("Y-m-d H:i:s",time());echo "<br>";echo date("Y-m-d H:i:s","1506494976");//字符串转换成时间戳echo "<br>";echo strtotime("2017-09-27 14:37:39");echo "<br>"; //取字符串的长度$str1 = "abcdefg";$str2 = "abc";//echo strlen();echo "<br>";//比较两个字符串,美国信息交换标准代码;var_dump(strcmp($str1,$str2));//转小写echo "<br>";strtolower($str2);//转大写//strtoupper();//拆分字符串echo "<br>";var_dump(explode("b",$str2)); //将数组元素拼接成一个字符串echo "<br>";echo implode("|",["a","b","c"]); //替换替换echo "<br>";//这里拿到是返回值,所以要用到echo输出一下;echo str_replace("cd","CD",$str1);echo "<br>";echo $str1; //替换指定位置的字符串echo "<br>";echo substr_replace($str1,"xxx",0,3); //截取字符串echo "<br>";echo substr($str1,1,3); //正则表达式$str =<<<A456abcdefghijklmn123A;echo "<br>";//上述所有字符的数字替换成#echo preg_replace("/\d/","#",$str);
时间: 2024-10-01 02:37:40