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.
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:
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!

The article compares ACID and BASE database models, detailing their characteristics and appropriate use cases. ACID prioritizes data integrity and consistency, suitable for financial and e-commerce applications, while BASE focuses on availability and

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

Article discusses best practices for PHP input validation to enhance security, focusing on techniques like using built-in functions, whitelist approach, and server-side validation.

The article discusses strategies for implementing API rate limiting in PHP, including algorithms like Token Bucket and Leaky Bucket, and using libraries like symfony/rate-limiter. It also covers monitoring, dynamically adjusting rate limits, and hand

The article discusses the benefits of using password_hash and password_verify in PHP for securing passwords. The main argument is that these functions enhance password protection through automatic salt generation, strong hashing algorithms, and secur

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

The article discusses strategies to prevent XSS attacks in PHP, focusing on input sanitization, output encoding, and using security-enhancing libraries and frameworks.

The article discusses the use of interfaces and abstract classes in PHP, focusing on when to use each. Interfaces define a contract without implementation, suitable for unrelated classes and multiple inheritance. Abstract classes provide common funct


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools