今日课程:PHP 3天基础巩固视频教程【燕十八】
1、递增递减运算符//先运算在输出
$b = 5; $a = $b++; var_dump($a,$b);//5,6 echo ‘<br />‘; $b = 5; $a = $b--; var_dump($a,$b);//5,4 echo ‘<br />‘; $b = 5; $a = ++$b; var_dump($a,$b);//6,6。1:把b的值+1,2:返回新值 echo ‘<br />‘; $b = 5; $a = --$b; var_dump($a,$b);//
2、字符串运算符//.
echo ‘<br />‘; $a = ‘hello‘; $b = ‘word‘; $c = $a . $b; var_dump($c); echo ‘<br />‘; $d = 112; $c = $c . $d; var_dump($c); //下列那个运算速度快 echo ‘<br />‘; $a = ‘hello‘; $b = ‘word‘; echo $a , $b;//运算更快 echo $a . $b;
3、赋值运算符
echo ‘<br />‘; $a = 3;//赋值运算,1:赋值给$a,2:返回运算结果 $res = ($a = 3); var_dump($res);
4、switch cash控制结构//swich case 适合用在验证多个可能的值,不适用判断范围,比如60-80几个。80-100优
echo ‘<br />‘; $tody == 1; if ($tody = 1) { echo "今天是星期1"; }else if($today == 2 ){ echo "今天是星期2"; }else if($today == 3 ){ echo "今天是星期3"; }else if($today == 4 ){ echo "今天是星期4"; }else if($today == 5){ echo "今天是星期5"; }else if($today == 6 ){ echo "今天是星期6"; }else if($today == 7){ echo "今天是星期7"; }else { echo "你来自火星"; } echo ‘<br />‘; $today = 3; switch ($today) { case 1: echo "今天是星期1"; break; case 2: echo "今天是星期2"; break; case 3: echo "今天是星期3"; break; case 4: echo "今天是星期4"; break; case 5: echo "今天是星期5"; break; case 6: echo "今天是星期6"; break; case 7: echo "今天是星期7"; break; default: echo "你来自火星"; }
5、while循环、do while(总能执行一次)
echo ‘<br />‘; $i = 0; while($i <= 10){ echo $i++,‘<br />‘; } $i = 100; do { echo $i++.‘<br />‘; } while ( $i <= 10); echo ‘<br />‘;
周末去玩了,昨天好累,今天继续努力到放弃,第五天~~
本文出自 “一条大大大大废鱼” 博客,谢绝转载!
原文:http://lonelyman.blog.51cto.com/9706318/1946428