$ _POST,$ _ GET和$ _REQUEST有什么区别? [英] What's the difference between $_POST, $_GET, and $_REQUEST?

查看:237
本文介绍了$ _POST,$ _ GET和$ _REQUEST有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对PHP中的这些超级全局变量($_POST$_GET$_REQUEST)有些困惑.在哪种情况下我需要在PHP中使用这些变量,这三个变量的主要区别是什么?

I am bit confused about these super global variable ($_POST, $_GET, and $_REQUEST) in PHP. In which scenario do I need to use these variables in PHP, and what are the main differences these three stand for?

推荐答案

$ _ POST 是使用application/x-www-时通过HTTP POST方法传递给当前脚本的变量的关联数组.表单编码或multipart/form-data作为请求中的HTTP Content-Type. 您可以在向服务器发送大数据时使用,也可以在拥有敏感信息(例如密码,信用卡详细信息等)的情况下使用

$_POST is an associative array of variables passed to the current script via the HTTP POST method when using application/x-www-form-urlencoded or multipart/form-data as the HTTP Content-Type in the request. You can use when you are sending large data to server or if you have sensitive information like passwords, credit card details etc

$ _ GET 是通过URL参数传递给当前脚本的变量的关联数组.您可以在数据量较少时使用,它主要用于分页,URL中显示页码,并且可以使用$ _GET

$_GET is an associative array of variables passed to the current script via the URL parameters. you can use when there is small amount of data, it is mostly used in pagination, page number is shown in the url and you can easily get the page number from URL using $_GET

$ _ REQUEST 是超全局变量"或自动全局变量.这只是意味着它可在整个脚本的所有作用域中使用.它是一个关联数组,默认情况下包含$ _GET,$ _ POST 和$ _COOKIE 的内容(取决于

$_REQUEST is a 'superglobal' or automatic global, variable. This simply means that it is available in all scopes throughout a script. It is an associative array that by default contains the contents of $_GET, $_POST and $_COOKIE (depending on request_order=)

这篇关于$ _POST,$ _ GET和$ _REQUEST有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆