Blogger Information
Blog 29
fans 0
comment 0
visits 25290
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP变量2019年2月20日作业
连界现代周伟的博客
Original
917 people have browsed it

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>

运行实例 »

点击 "运行实例" 按钮查看在线实例

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post