<?php
// 1.从数据库中取若干条数据 php mysql sql 读数据返回
// 2. js遍历 for... forEach | php遍历 foreach for
//3.php中的foreach和endforeach相当于js中的{}
//模拟数据库数据集合
$danChes = ['小黄车', '小蓝车', '小桔车'];
?>
<!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>共享单车</title>
</head>
<body>
<h2><? echo '共享单车'?></h2>
<ol>
<!-- php的语法 : -->
<? foreach ( $danChes as $danChe ):?>
<li style = 'color:red'>
<a href = ''><? echo $danChe?></a>
</li>
<?endforeach?>
</ol>
<!-- js的语法 : -->
<script type = 'text/javascript'>
let danChes = ['小黄车', '小蓝车', '小桔车'];
for ( let i = 0; i < danChes.length; i++ ) {
alert( danChes[i] );
}
</script>
</body>
</html>