Correction status:qualified
Teacher's comments:
PHP就是服务器端用来把PHP文件转换成服务器APpache能识别的HTML文档的超文本语言,是用户和数据库、服务器进行交互的编码器。
PHP变量的运用实例:
<?php $title = '学生成绩管理系统'; $tableTitle = '学生成绩表'; $stu1 = [1,'小李','数学',90]; $stu2 = [2,'小红','数学',85]; $stu3 = [3,'小张','数学',95]; $stu4 = [4,'小王','数学',93]; $totel = 4; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title><?php echo $title ?></title> <style> table,th,td { border: 1px solid #ccc; padding: 8px; } table { border-collapse: collapse; width: 80%; text-align: center; margin: 30px auto; } thead tr:first-of-type { background-color: lightblue; } tbody tr:hover { background-color: #efefef; } table > caption { font-size: 1.2rem; margin-bottom: 15px; } table + p { text-align: center; } </style> </head> <body> <table> <caption><?php echo $tableTitle ?></caption> <thead> <tr> <th>学号</th> <th>姓名</th> <th>科目</th> <th>成绩</th> </tr> </thead> <tbody> <?php echo '<tr>'; echo "<td>{$stu1[0]}</td>"; echo "<td>{$stu1[1]}</td>"; echo "<td>{$stu1[2]}</td>"; echo "<td>{$stu1[3]}</td>"; echo '</tr>'; echo '<tr>'; echo "<td>{$stu2[0]}</td>"; echo "<td>{$stu2[1]}</td>"; echo "<td>{$stu2[2]}</td>"; echo "<td>{$stu2[3]}</td>"; echo '</tr>'; echo '<tr>'; echo "<td>{$stu3[0]}</td>"; echo "<td>{$stu3[1]}</td>"; echo "<td>{$stu3[2]}</td>"; echo "<td>{$stu3[3]}</td>"; echo '</tr>'; echo '<tr>'; echo "<td>{$stu4[0]}</td>"; echo "<td>{$stu4[1]}</td>"; echo "<td>{$stu4[2]}</td>"; echo "<td>{$stu4[3]}</td>"; echo '</tr>'; ?> </tbody> </table> <p>总计<?php echo $totel ?>人</p> </body> </html>
点击 "运行实例" 按钮查看在线实例