一、随机数和时间
//随机数生成器(JS:math.random)
echo rand();
//生成某个范围内的随机数
echo rand(0,10);
//时间戳
echo time();
//格式化显示时间
echo "<br>";
echo date("Y-m-d H:i:s",time());
echo "<br>";
echo date("Y-m-d H:i:s","101506494366");
//将字符串转化时间戳
echo "<br>";
echo strtotime("2017-09-27 14:49:13");
echo "<br>";
二、字符串函数
//长度 str.length
$str1 = "abcdefg";
$str2 = "abcd";
echo strlen($str1);
//比较两个字符串长度
echo "<br>";
var_dump(strcmp($str1,$str2));
//转小写
echo "<br>";
echo strtolower("ABCDE");
//转大写
echo "<br>";
//strtoupper();
//拆分字符串,返回数组
echo "<br>";
var_dump(explode("b",$str2));
//将数组元素拼接成一个字符串
echo "<br>";
echo implode("|",["a","b","c"]);
//查找替换
echo "<br>";
echo str_replace("cd","CD",$str1);
//替换指定位置字符
echo "<br>";
echo substr_replace($str1,"xxx",0,3);
//截取字符串
echo "<br>";
echo substr($str1,1,3);