Correcting teacher:灭绝师太
Correction status:qualified
Teacher's comments:加油,课程慢慢跟上来~
<?php
$cars=['1系PHP','3系PHP','5系PHP'];
$coolcars=['2系PHP','4系PHP','7系PHP'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BMW好车</title>
</head>
<body>
<h2><? echo '宝马好车(无循环)'?></h2>
<ol>
<li><a href=""><? echo '1系'?></a></li>
<li><a href=""><? echo '3系'?></a></li>
<li><a href=""><? echo '5系'?></a></li>
</ol>
<h2><? echo '宝马好车(PHP foeach)'?></h2>
<ol>
<!--
未使用模版语法
-->
<? foreach($cars as $car){?>
<li><a href=""><? echo $car ?></a></li>
<? } ?>
<!--
if,while,for,forforeach,switch这些流程控制语句都有替代语法。
:代替了左边的花括号{
并用endforeach代替结束时的右边的花括号} -->
<? foreach($coolcars as $coolcar):?>
<li><a href=""><? echo $coolcar ?></a></li>
<? endforeach ?>
</ol>
<!-- JS for循环 演示 -->
<script type="text/javascript">
let cars=['1系PHP','3系PHP','5系PHP'];
for (let index = 0; index < cars.length; index++)
{
alert(cars[index]);
}
</script>
</body>
</html>