Correction status:qualified
Teacher's comments:1. 四个小时完成, 对于新人来说是正常的;
2. 英文注释比较另类, 但目前还是推荐使用中文
3. GitHub打开太慢了,你在HK,咱们比不了
<?php // header include __DIR__ . "/component/header.php"; //build html template by php echo '<ol>'; foreach ( $cates as $cate ): // echo title echo '<h2>' . $cate['name'] . '</h2>'; //echo list foreach ( $foods as $food ): //find same id if ( $cate['cate_id'] === $food['cate_id'] ) { echo '<li><a href="detail.php?foods_id=' . $food['foods_id'] . '">' . $food['name'] . '</a></li>'; } endforeach; endforeach; echo '</ol>'; // footer include __DIR__ . '/component/footer.php';
点击 "运行实例" 按钮查看在线实例
<?php // 加载公共头部 include __DIR__ . '/component/header.php'; //get the cate_id to show which pages $integerId = intval( $_GET['cate_id'] ); echo '<ol>'; foreach ( $cates as $cate ): if ( $integerId == $cate['cate_id'] ) { echo '<h2>' . $cate['name'] . '</h2>'; foreach ( $foods as $food ): if ( $cate['cate_id'] == $food['cate_id'] ) { echo '<li><a href="detail.php?foods_id=' . $food['foods_id'] . '">' . $food['name'] . '</a></li>'; } endforeach; } endforeach; echo '</ol>'; // 加载公共底部 include __DIR__ . '/component/footer.php';
点击 "运行实例" 按钮查看在线实例
<?php // 加载公共头部 include __DIR__ . '/component/header.php'; $integerId = intval( $_GET['foods_id'] ); foreach ( $foods as $food ): if ( $integerId == $food['foods_id'] ) { echo $food['name'] . '<br>'; echo $food['detail']; } endforeach; // 加载公共底部 include __DIR__ . '/component/footer.php';
点击 "运行实例" 按钮查看在线实例
作業上傳到github中。
https://github.com/beebb0128/php.cn