MySQL_PHP学习笔记_2015_0614_PHP传参总结_URL传参_表单传参

1. PHP 传参总结

  1.1 url 传参

    解析方法(下面两种解读方式均可以):

$firstName1 = $_GET['firstName'];
$firstName2 = $_REQUEST['firstName'];

    传参方法:

<a href="name.php?firstName=Kevin&lastName=Yank"> Hi, I'm Kevin!</a>

  1.2 表单传参

    解析方法(下面两种解读方式均可以):

$firstName = $_REQUEST['firstName'];
$lastName = $_POST['lastName'];

    传参方法:

<form action="name_form.php" method="post">
    <div>
      <label for="firstName">First Name:
        <input type="text" name="firstName" id="firstName">
      </label>
    </div>
    <div>
      <label for="lastName">Last Name:
        <input type="text" name="lastName" id="lastName">
      </label>
    </div>
    <div>
      <input type="submit" value="GO">
    </div>
  </form>
posted @ 2015-09-06 09:58  leungcnblogs  阅读(280)  评论(0编辑  收藏  举报