search
HomeBackend DevelopmentPHP Problemwhat is php superglobal variable array

Super global variables in PHP are a type of predefined global variable array that can be used in scripts and can be accessed without declaration by the developer. These arrays include $_GET, $_POST, $_REQUEST, $_COOKIE, etc.

what is php superglobal variable array

Operating system for this tutorial: Windows 10 system, php8.1.3 version, Dell G3 computer.

PHP Super Global Array, also known as PHP predefined array, is built into the PHP engine and does not need to be redefined by developers. When a PHP script runs, PHP automatically places some data in a super global array.

1. The $_GET array is used to collect form data submitted through the GET method, usually in the form of URL parameters

<form action="process.php" method="get">
  Name: <input type="text" name="name"><br>
  Age: <input type="text" name="age"><br>
  <input type="submit">
</form>
// process.php
$name = $_GET[&#39;name&#39;];
$age = $_GET[&#39;age&#39;];
echo "Welcome $name! You are $age years old.";

2. The $_POST array is used to collect form data submitted through the POST method. , can be used to process sensitive data

<form action="process.php" method="post">
  Name: <input type="text" name="name"><br>
  Age: <input type="text" name="age"><br>
  <input type="submit">
</form>
// process.php
$name = $_POST[&#39;name&#39;];
$age = $_POST[&#39;age&#39;];
echo "Welcome $name! You are $age years old.";

3. The $_REQUEST array contains the contents of GET, _POST, and $_COOKIE. Can be used to collect data after HTML form submission or obtain data from the browser address bar.

<form action="process.php" method="post">
  Name: <input type="text" name="name"><br>
  Age: <input type="text" name="age"><br>
  <input type="submit">
</form>
// process.php
$name = $_REQUEST[&#39;name&#39;];
$age = $_REQUEST[&#39;age&#39;];
echo "Welcome $name! You are $age years old.";

4. The $_COOKIE array is used to access cookies that have been stored on the client computer

// send_cookie.php
setcookie(&#39;username&#39;, &#39;John&#39;, time() + (86400 * 30), "/"); // 设置 cookie
echo &#39;Cookie sent.

The above is the detailed content of what is php superglobal variable array. 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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.