这次实践的都是PHP7的语法。
感觉是以前的5差别不是那么大,只是希望越来越快吧。
$looking = isset($_GET['title']) || isset($_GET['author'])
?>
BookStoreecho "Befor the conditional.
";
if (2 > 2) {
echo "Inside the conditional.
";
} elseif ( 2 == 2) {
echo "Print when 2 == 2.
";
} elseif ( 2 < 2) {
echo "Not evaluted.
";
} else {
echo "Inside the else.
";
}
echo "After the conditional.
";
$title = 'Harry Potter';
switch ($title) {
case 'Harry Potter':
echo 'Nice story. a bit too long.';
break;
case 'Load of the Rings':
echo 'A classic!';
break;
default:
echo 'Dunno that one.';
break;
}
echo "
";
$i = 1;
while ($i < 4) {
echo $i . "
";
$i++;
}
echo "
";
$i = 1;
do {
echo $i . "
";
$i++;
} while ($i < 0);
for ($i = 1; $i < 10; $i++) {
echo $i . "
";
}
$names = ['Harry', 'Ron', 'Hermione'];
for ($i = 0; $i < count($names); $i++) {
echo $names[$i] . "
";
}
foreach ($names as $name) {
echo $name . "
";
}
foreach ($names as $key => $name) {
echo $key . ' -> ' . $name . "
";
}
?>
输出:
Befor the conditional.
Print when 2 == 2.
After the conditional.
Nice story. a bit too long.
1
2
3
1
1
2
3
4
5
6
7
8
9
Harry
Ron
Hermione
Harry
Ron
Hermione
0 -> Harry
1 -> Ron
2 -> Hermione
标签:语句,++,Hermione,conditional,echo,names,Harry,PHP,分支
来源: https://www.cnblogs.com/aguncn/p/11120146.html