<?php
//A例子
$num = 2; //条件 = 2
$sum = 10;
switch($num){//执行(从条件2开始执行)
case 1://case/事例
$sum = $sum + 1000;
case 2:
$sum = $sum + 10;
break;//break/打破(中断)
case 3:
$sum = $sum + 10;
default:
$sum = $sum + 10;
}
echo "A例子的值是:".$sum."<br />";
//A例子
$num = 2; //条件 = 2
$sum = 10;
switch($num){//执行(从条件2开始执行)
case 1://case/事例
$sum = $sum + 1000;
case 2:
$sum = $sum + 10;
break;//break/打破(中断)
case 3:
$sum = $sum + 10;
default:
$sum = $sum + 10;
}
echo "A例子的值是:".$sum."<br />";
2018-03-09
function position($maxline,$no){
$line = ceil($no/$maxLine);
$row = $no%$maxLine?$no%$maxLine:$maxLine;
echo $line," ",$row;
}
position(4,20);
$line = ceil($no/$maxLine);
$row = $no%$maxLine?$no%$maxLine:$maxLine;
echo $line," ",$row;
}
position(4,20);
2018-03-09
@IT习者 (第二部分)
$sum = 0;
do{
$num = rand(1,6);
$sum = $sum + $num;
echo "这次掷除了".$num."点";
echo "<br />";
}while($num==6);
echo "do...while例子执行完毕,前进:".$sum ."<br />";
?>
$sum = 0;
do{
$num = rand(1,6);
$sum = $sum + $num;
echo "这次掷除了".$num."点";
echo "<br />";
}while($num==6);
echo "do...while例子执行完毕,前进:".$sum ."<br />";
?>
2018-03-08
@IT习者
<?php
$sum = 0;
$num = rand(1,6);
echo "第一次次掷出了".$num."点";
echo "<br />";
$sum = $sum + $num;
while($num==6){
$num = rand(1,6);
echo "第二次掷出了".$num."点";
echo "<br />";
$sum = $sum + $num;
};
echo "while例子执行完毕,前进:".$sum ."<br />";
<?php
$sum = 0;
$num = rand(1,6);
echo "第一次次掷出了".$num."点";
echo "<br />";
$sum = $sum + $num;
while($num==6){
$num = rand(1,6);
echo "第二次掷出了".$num."点";
echo "<br />";
$sum = $sum + $num;
};
echo "while例子执行完毕,前进:".$sum ."<br />";
2018-03-08
foreach($students as $k => $v){
echo $k."--".$v;//输出(打印)姓名
echo "<br />";
}
echo $k."--".$v;//输出(打印)姓名
echo "<br />";
}
2018-03-08
<?php
$love = "I love you!";
$string1 = "刘和娟,$love";
$string2 = '刘和娟,$love';
echo $string1;
echo "<br />";
echo $string2;
?>
$love = "I love you!";
$string1 = "刘和娟,$love";
$string2 = '刘和娟,$love';
echo $string1;
echo "<br />";
echo $string2;
?>
2018-03-08
<?php
$str_string1 = '刘和娟是我梦中女孩';
$str_string2 = "我还是忘不了她";
echo $str_string1;
echo "<br />";
echo $str_string2;
?>
$str_string1 = '刘和娟是我梦中女孩';
$str_string2 = "我还是忘不了她";
echo $str_string1;
echo "<br />";
echo $str_string2;
?>
2018-03-08