实例
<?php /** * Created by PhpStorm. * User: ymz * Date: 2019-4-15 * Time: 21:59 */ $headline="GET"; if(!empty($_GET)){ $user=$_GET['user']; $pw=$_GET['password']; echo '<pre><br><hr><b>'.$headline.'输出:</b><hr>'; print_r($_GET); echo '</pre>'; } ?> <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title><?php echo $headline;?></title> <style type="text/css"> div{width: 400px; height: 300px;margin: 50px auto;border:1px solid blue;padding: 10px;} h2{text-align: center;} </style> </head> <body> <div> <h2><?php echo $headline; ?></h2> <hr> <form action="" method="get"> <p> <label>用户:</label> <input type="text" name="user" value="<?=(!empty($user))?$user:'';?>"> </p> <p><label>密码:</label> <input type="password" name="password" value="<?=(!empty($pw))?$pw:'';?>"> </p> <p> <button>提交</button> </p> </form> </div> </body> </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例
get方法的应用,主要是键值对,但容易暴露一些敏感信息。