1.打印出昨天此时的时刻的时间戳。
<?php
date_default_timezone_set("Asia/Shanghai");
echo "Time now:".date("Y-m-d H:i:s").'<br/>';
echo "The time of this moment yesterday:".date("Y-m-d H:i:s",strtotime("-1 day"));
2.获取以下文件的后缀 $str = 'C:xampphtdocsphp-11.php';
<?php
$str = 'C:xampphtdocsphp-11.php';
echo "String Length".strlen($str).'<br/>';
echo substr($str,23,27).'<br/>';
echo strstr($str,'.');
3.写一个生成随机验证码的函数。
<?php
function random(){
$key = '';
$pattern = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ0123456789';
for($i = 0;$i < 4;$i++){
$key = $key.$pattern[mt_random(0,61)];
}
return $key;
}
echo random();
4.有一数组$a=array(8,2,7,5,1);请将其重新排序,按从小到大的顺序输出。
<?php
$a=array(8,2,7,5,1);
echo ':';
$sort_a = sort($a);
print_r($a);