PHP PHP GET和POST变量

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP PHP GET和POST变量相关的知识,希望对你有一定的参考价值。

<?php
/*
PHP GET and POST Variables

The following code will easily retrieve all of the GET and POST data for you and load it into appropriately named PHP variables. The same code will also work to get parameters added to the end of URLs via other methods other than using GET with a form. */

$q = explode("&",$_SERVER["QUERY_STRING"]);
foreach ($q as $qi)
{
  if ($qi != "")
  {
    $qa = explode("=",$qi);
    list ($key, $val) = $qa;
    if ($val)
      $$key = urldecode($val);
  }
}
 
reset ($_POST);
while (list ($key, $val) = each ($_POST))
{
  if ($val)
    $$key = $val;
}
?>

以上是关于PHP PHP GET和POST变量的主要内容,如果未能解决你的问题,请参考以下文章

php高级

PHP $_GET与$_POST

PHP超级全局变量

PHP 使用PHP为所有表格变量(POST / GET)创建插入MYSQL

php超全局变量

PHP 介绍php的一些基本语法,配合wamp,跟着案例来学习GET和POST请求( 非常详细 )