Correcting teacher:天蓬老师
Correction status:qualified
Teacher's comments:
1.算术运算符:
++
、--
;先加(减)再用,先用后加(减)**
;例如:1的三次方1**32.字符串运算符:.
字符传连接符
3.赋值运算符:
4.比较运算(返回布尔值)
<=>
;例如:$a<=>$b
,如果$a>$b返回大于0的整数,如果$a=$b返回等于0的整数,如果$a<$b返回小于0的整数;1.分支语句:
判单条件?"返回值1":"返回值2"
2.循环语句:
while循环:
for循环:for(初始条件;判断条件;循环条件){语句}
foreach($arr as $item){
//遍历数组中的值
echo $item;
}
3.语句分支的模板写法:
{}
,用冒号代替:
if($a>5):
echo $a;
elseif($a<10):
echo ++$a;
endif;
switch($a):
case 5:
echo $a;
break;
default:
echo $a+$b;
endswitch;
echo "<br>";
$arr=["one","two","three"];
for($i=0;$i<count($arr);$i++):
echo $arr[$i]."<br>";
endfor;
foreach($arr as $item):
echo $item;
endforeach;
<?php
$a=10;
$b=6;
echo "/取商运算:",$a/$b,'<br>';
echo "%取余运算:",$a%$b,'<br>';
echo "<br>";
echo "round取四舍五入取整运算:",round($a/$b),'<br>';
echo "ceil向上取整运算:",ceil($a/$b),'<br>';
echo "floor向下取整运算:",floor($a/$b),'<br>';
echo "intdiv取整相除运算:",intdiv($a,$b),'<br>';
echo $a**$b;
echo "<br>";
echo ++$a;
echo $a;
echo "<br>";
echo $a--;
echo $a;
echo "太空运算符";
var_export($a<=>$b);
echo "###################";
echo "<br>";
if($a>5):
echo $a;
elseif($a<10):
echo ++$a;
endif;
switch($a):
case 5:
echo $a;
break;
default:
echo $a+$b;
endswitch;
echo "<br>";
$arr=["one","two","three"];
for($i=0;$i<count($arr);$i++):
echo $arr[$i]."<br>";
endfor;
foreach($arr as $item):
echo $item;
endforeach;
require "demo.php";//导入文档内容,
include "demo1.php";