Correction status:qualified
Teacher's comments:你的作业看上去似乎没有写完吧....
一、混编
<?php $title='混编'; $bt = '精品国漫'; $nr=['画江湖之不良人','超神学院','魔道祖师']; ?> <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title><?php echo $title; ?></title> <style type="text/css"> li{ list-style: none; } </style> </head> <body> <h2><?php echo $bt; ?></h2> <ul> <li><a href=""><?php echo $nr[0] ?></a></li> <li><a href=""><?php echo $nr[1] ?></a></li> <li><a href=""><?php echo $nr[2] ?></a></li> </ul> <!--循环遍历输出数组--> <?php foreach ($nr as $key=>$value) { echo $key+1 . ': ' . $value . '<br>'; } ?> <hr> <!--使用 php 输出 html--> <?php echo '<ul>'; foreach ($nr as $key=>$value) { echo '<li><a href="">' . ($key+1) . ': ' . $value . '</a></li>'; } echo '</ul>'; ?> <hr> <!--使用 php + html 混编--> <ul> <?php foreach ($nr as $key=>$value) { ?> <li><a href=""><?php echo ($key+1) . ':' . $value; ?></a></li> <?php } ?> </ul> <hr> <!--使用foreach替大括号--> <ul> <!--使用php循环结构的替代语法--> <?php foreach ($nr as $mc): ?> <li><a href=""><?php echo $mc; ?></a></li> <?php endforeach;?> </ul> </body> </html>
点击 "运行实例" 按钮查看在线实例
二、get与post
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>get与post</title> </head> <body> <!--get方法--> <br><br> <form action="" method="get"> <label for="username">用户名:</label> <input type="text" id="username" name="username" value="<?php echo isset($_GET['username']) ? $_GET['username'] : ''; ?>"> <label for="password">密码:</label> <input type="password" id="password" name="password" value="<?php echo isset($_GET['password']) ? $_GET['password'] : ''; ?>"> <button>登录</button> </form> <?php echo '<pre>'. print_r($_GET); ?> <br><br><br><br> <!--post方法--> <form action="" method="post"> <label for="username">用户名:</label> <input type="text" id="username" name="username" value="<?php echo isset($_POST['username']) ? $_POST['username'] : ''; ?>"> <label for="password">密码:</label> <input type="password" id="password" name="password" value="<?php echo isset($_POST['password']) ? $_POST['password'] : ''; ?>"> <button>登录</button> </form> <?php echo '<pre>'. print_r($_POST); ?> </body> </html>
点击 "运行实例" 按钮查看在线实例