Php $ _ POST $ _ GET and $ _ REQUEST

Source: Internet
Author: User
Tags php tutorial

In the php Tutorial, there are many methods to obtain parameters transmitted from the form and url. Next we will introduce the code principles and methods for obtaining the submitted form from $ _ post and $ _ request.

$ _ Post: it can only receive data when php obtains the method = "post" of the form. The following code

<Form id = "form1" name = "form1" method = "get" action = "">
<Input type = "text" name = "cn" value = 'get me'/>

A. php page

If ($ _ post)
Echo $ _ post ['cn'];
Echo 'no value obtained ';

The value obtained is get me. If we get the method = "get" of the form, we need to get it with $ _ get, as shown below:

Echo $ _ get ['cn']; // This is also a value.

How can we use $ _ request?

Echo $ _ request ['cn'];

// No matter whether your form's method is get or post or a value passed from the url parameter, you can get it.

So what are the differences between them? According to my summary, $ _ post and $ _ get are efficient to $ _ request. I will understand the difference after a careful consideration, because the first two are targeted, naturally, do not judge whether they are post or get data. For page $ _ request, he must judge that the submitted data is in that form, this takes some time.

Note: This site Original tutorial reprint indicate source http://www.111cn.nethttp: //

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.