Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:
//加密
echo md5('abcde');//ab56b4d92b40713acc5af89985d4b786
echo '<hr/>';
echo sha1('abcde');//03de6c570bfe24bfc328ccd7ca46b76eadaf4334
echo '<hr/>';
//...归并参数
function sum(...$args){
$sum=0;
foreach($args as $key=>$value){
$sum += $value;
};
return $sum;
}
echo sum(1,2,3,4,5,6,7,8,9,10);
//数组函数
//count() 统计数组元素属性的个数
$arr=[
'name'=>'zhang',
'sex'=>'male',
'age'=>18,
'name1'=>'zhang',
'sex1'=>'male',
'age1'=>32
];
echo count($arr);
echo '<hr/>';
//删除数组元素
unset($arr['sex']);
print_r($arr);
//删除数组中重复的元素(值重复)
print_r(array_unique($arr));
//合并两个数组
$arr1 = [
'join',
'shu'
];
print_r(array_merge($arr,$arr1));
//将数组的元素值转成按指定的分隔符分割的字符串
$arrStr = implode(',',$arr);
echo $arrStr;
echo '<hr/>';
//将指定分隔符分割的字符串转为数组(索引数组)
$arrResult = explode(',',$arrStr);
print_r($arrResult);
条件分支语句
//三元运算符 表达式?语句块1:语句块2;
$rq = '二';
$w = ($rq == '六' or $rq == '日') ? '休息' : '上课' ;
echo $w;
echo '<hr/>';
//if语句
$total = '85';
if($total >= 90){
echo '优秀';
}else if($total >= 80){
echo '良好';
}else if($total >= 60){
echo '及格';
}else{
echo '不及格';
}