這裡的題目都是比較老的,但是做筆試題時經常碰到,因為這些題目比較凌亂,考的知識點不好分類,就放一塊了
/**
* 題目:最少代碼實現求3個數的最大值
* 三目運算符實現
*/
function getMax($a,$b,$c){
return ($a > $b) ? ( ($a > $c) ? $a : $c ) : ( ($b > $c) ? $b : $c );
}
echo getMax(3,9,6)
/**
* 題目:打印前一天的時間 格式:2015年10月15日 11:09:33
* strtotime函數使用
* strtotime("now")
* strtotime("-1 day");
* strtotime("+1 day");
* strtotime("+2 days");
* strtotime("+1 week");
* strtotime("+1 month");
* strtotime("+2 hours");
* strtotime("next Monday");
* strtotime("last Monday");
* strtotime("+1 week 3 days 7 hours 5 seconds");
*/
date_default_timezone_set("PRC");
echo date("Y-m-d H:i:s",strtotime("-1 day"));