Document directory
The PHP $ _ get $ _ Get variable is an array with the variable name and value sent by the http get method. PHP $ _ post
The $ _ post variable is used to collect the values in the form from method = "Post.
$ _ Post variable
The $ _ post variable is an array with the variable name and value sent by the http post method.
The $ _ post variable is used to collect the values in the form from method = "Post. The information sent from a form with the POST method is invisible to anyone (displayed in the address bar of the browser) and there is no limit on the amount of information sent.
Example
<form action="welcome.php" method="post"
> Enter your name: <input type="text" name="name" /> Enter your age: <input type="text" name="age" /> <input type="submit" /> </form>
When a user clicks the submit button, the URL does not contain any form data and looks like this:
http://www.w3school.com.cn/welcome.php
The "Welcome. php" file can now get form data using the $ _ post variable (note that the name of the form field will automatically become the ID key in the $ _ post array ):
Welcome <?php echo $_POST["name"]
; ?>.<br /> You are <?php echo $_POST["age"]
; ?> years old!
Why use $ _ post?
- Variables sent through http post are not displayed in the URL.
- The variable has no length limit.
However, because the variables are not displayed in the URL, the page cannot be added to the bookmarks.
$ _ Request variable
The $ _ Request variable in PHP contains $ _ Get, $ _ post, and $ _ cookie content.
The $ _ Request variable of PHP can be used to obtain the results of form data sent through the get and post methods.
Example
Welcome <?php echo $_REQUEST["name"]; ?>.<br /> You are <?php echo $_REQUEST["age"]; ?> years old!
Attention: use $ _ Request with caution
If a get change order name is the same as a post variable name, the post value overwrites the get variable value.
Assume that reqyest first obtains the get value and then the post value. The post value overwrites the get value.
Let's look at the configuration in PHP. ini.
; This directive describes the order in which PHP registers GET, POST, Cookie,
; Environment and Built-in variables (G, P, C, E & S respectively, often
; referred to as EGPCS or GPC). Registration is done from left to right, newer
; values override older values.
variables_order = "EGPCS"
This egpcs indicates the priority of the content obtained using the $ _ Request array. The letter meanings are as follows:E-generation table $ _ ENV, G stands for $ _ Get, P stands for $ _ post, C stands for $ _ cookie, and S stands for $ _ Session. The subsequent data will overwrite the previously written data. The default data writing method is egpcs.So the data contained in the post will overwrite the data with the same keyword in get.
Through this we can also see the steps for PHP to obtain parameters
Environment Variable = get = post = cookie => session