Home > Backend Development > PHP Tutorial > php $_get[] usage_PHP tutorial

php $_get[] usage_PHP tutorial

WBOY
Release: 2016-07-13 16:59:05
Original
1419 people have browsed it

php教程中$_get要获取表单的数据那必须把METHOD=GET才行,否则就无法正常获取值哦,

$_GET 变量是一个数组,内容是由 HTTP GET 方法发送的变量名称和值。

$_GET 变量用于收集来自 method="get" 的表单中的值。从带有 GET 方法的表单发送的信息,对任何人都是可见的(会显示在浏览器的地址栏),并且对发送的信息量也有限制(最多 100 个字符)。


看个获取表单数据的实例



//Properly determining which submission button was clicked in PHP:

if(isset($_GET['submit_one_x'])) {

} elseif(isset($_GET['submit_two_x'])) {
} else {

}
?>

实例二



Enter your message (5 minute time limit):

if($_GET['time']+300 >= time()) {
     echo "You took too long!
";
     exit;
}
?>

操作select值


//The PHP code to access which value(s) were selected:

     foreach($_GET['myselect'] as $val) {
          echo "You selected: $val
";
     }
     echo "You selected ".count($_GET['myselect'])." Values.";
?>

获取表单提交的数据再输出,这也是个完整的实例



A Simple HTML Form












// index.php



  print "Welcome " . $_GET ['user'] . "
nn";
  print "Your address is:
" . $_GET ['address'] . "";
  ?>
 


Note: When using $_GET variables, all variable names and values ​​will be displayed in the URL. So this method should not be used when sending passwords or other sensitive information. However, because the variables appear in the URL, you can bookmark the page. In some cases this is useful.

Note: The HTTP GET method is not suitable for large variable values; values ​​cannot exceed 100 characters

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631338.htmlTechArticleIn the $_get tutorial to get the form data, you must set METHOD=GET, otherwise it will not be obtained normally. Value, $_GET variable is an array, the content is the variable sent by the HTTP GET method...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template