作业1
实例
<?php $home='我爱我家'; $member=[0=>'爸爸',1=>'妈妈',2=>'我']; ?> <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title><?php echo $home; ?></title> </head> <body> <h2><?php echo $home; ?></h2> <ul> <?php foreach ($member as $member): ?> <li><a href=""><?php echo $member; ?></a></li> <?php endforeach;?> </ul> <!--使用foreach替代语法,干掉大括号, 将大括号用冒号代替--> </body> </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例
作业2get
实例
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>get作业</title> </head> <body> <form action="" method="get"> <p> <label for="user">用户:</label> <input type="text" id="user" name="user" value=""> </p> <p> <label for="password">密码:</label> <input type="password" id="password" name="password" value=""> </p> <p> <button>登录</button> </p> </form> </body> </html> <?php echo isset($_GET['user']) ? $_GET['user'] : ''; echo isset($_GET['password']) ? $_GET['password'] : ''; //echo '<pre>'; //print_r($_GET); ?>
运行实例 »
点击 "运行实例" 按钮查看在线实例
作业2POST
实例
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>POST作业</title> </head> <body> <form action="" method="POST"> <p> <label for="user">用户:</label> <input type="text" id="user" name="user" value=""> </p> <p> <label for="password">密码:</label> <input type="password" id="password" name="password" value=""> </p> <p> <button>登录</button> </p> </form> </body> </html> <?php echo isset($_POST['user']) ? $_POST['user'] : ''; echo isset($_POST['password']) ? $_POST['password'] : ''; ?>
运行实例 »
点击 "运行实例" 按钮查看在线实例