Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:
<?php
$items = ['苹果','香蕉','水蜜桃','梨子'];
?>
<ol>
<?php foreach( $items as $item ):?>
<li>
<?php echo $item ?>
</li>
<?php endforeach?>
</ol>
<?
$items = ['苹果','香蕉','水蜜桃','梨子'];
?>
<ol>
<?foreach( $items as $item ):?>
<li>
<? echo $item ?>
</li>
<?endforeach?>
</ol>
<ol id="list"></ol>
<script type="text/javascript">
let items = ['苹果1','香蕉1','水蜜桃1','梨子1'];
let Li= document.getElementById('list');
for (let i = 0; i < items.length; i++) {
var LI = document.createElement('li')
LI.innerHTML = items[i];
Li.appendChild(LI)
}
</script>
PHP | Javascript | |
---|---|---|
区别 | 使用模板语法直接嵌入HTML | 需要DOM操作 |
注意点 | 注意起始与结束 | 作用域 |