$ _POST,$ _GET,$ _REQUEST有什么区别? [英] $_POST, $_GET, $_REQUEST What's the difference?

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

问题描述

php 中的这些超级全局变量( $ _ POST,$ _GET,$ _REQUEST ), 。我想知道我需要在 php 中使用这些变量的哪个场景,以及这三个主要区别是什么? $ _ POST 是一个通过HTTP POST方法传递给当前脚本的变量的关联数组。在请求中使用application / x-www-form-urlencoded或multipart / form-data作为HTTP Content-Type时。
您可以在您向服务器发送大量数据时使用,或者您有密码,信用卡详细信息等敏感信息。

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



轻松获取网页中的页码$ _ REQUEST
是'超全球'或自动全局变量。这仅仅意味着它在整个脚本的所有范围内都可用。它是一个关联数组,默认情况下包含$ _GET,$ _POST <和> _COOKIE 的内容(取决于 request_order =


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

解决方案

$_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 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 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天全站免登陆