Home >Backend Development >PHP Problem >What are the predefined variables in php

What are the predefined variables in php

(*-*)浩
(*-*)浩Original
2019-10-08 13:07:003182browse

PHP provides a large number of predefined variables. These variables represent all external variables as built-in environment variables and error messages as return headers.

What are the predefined variables in php

Predefined variables are also called super global variables, including: (Recommended learning: PHP video tutorial)

$ _GET, $_POST, $_SERVER, $_REQUEST, $GLOBALS, $_COOKIE, $_SESSION, $_ENV, $_FILES, $php_errormsg, $HTTP_RAW_POST_DATA, $http_response_header, $argc, $argv

Pre The scope in which variables are defined is called the "superglobal scope": the global scope is the sum of the local scopes (all available inside and outside the function)

Superglobal variables are all arrays!

For example, $_GET variable (array):

The word get often appears here: 4073b92f21d77585ac28a8f0ef9ce29f....f5a47148e367a6035fd7a2faa965022e

This is called "the form submits data in get mode"

Then the $_GET predefined array variable means to The collection (array) of all data submitted in this way

Correspondingly, data can also be submitted in post mode

Note: The word get does not seem to have a Chinese translation.

Actually, in web pages, there are many forms of submitting data in get mode:

Form 1:

<form  action=”abc.php”  method=”get” >
项目1: <input type=”text”   name=”uName”   />
项目2: <input type=”password”   name=”uPswd”   />
<input type=”submit”  value=”提交”  />
</form>

Its function is: User After filling in the form data and submitting it, the data will be sent (submitted) to the page abc.php. In fact, it can also be understood as "opening" the webpage (abc.php), or "requesting" the webpage (abc.php). )

Form 2:

<a  href=”abc.php?uName=test1&uPswd=123”  > 文字。。。</a>

Its function is: after the user clicks the link, the data will be sent (submitted) to the page abc.php. In fact, it can also be understood as "Opening" the webpage (abc.php) can also be understood as "requesting" the webpage (abc.php). This request is also a get request

Form 3:

<script>
location.href = “abc.php?uName=test1&uPswd=123”; //利用location对象的属性href
</script>

The function is: when this line of statement is executed (usually in a function), the data will be sent (submitted) to the page abc.php. In fact, it can also be understood as "opening" the web page (abc. php), can also be understood as "requesting" the web page (abc.php). This request is also a get request

Form 4:

<script>
location.assign( “abc.php?uName=test1&uPswd=123”); //利用location对象的方法assign()
</script>

Its function is: When this line of statement is executed (usually in a function), the data will be sent (submitted) to the page abc.php. In fact, it can also be understood as "opening" the web page (abc.php), or " Request" this webpage (abc.php), this request is also a get request

The above is the detailed content of What are the predefined variables in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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