search
HomeBackend DevelopmentPHP ProblemAre php global variables shared?

Are php global variables shared?

Sep 27, 2019 pm 03:13 PM
php

Several super global variables (superglobals) are predefined in PHP, which means that they are available in the entire scope of a script. You can use it in functions and classes without special instructions.

Are php global variables shared?

##PHP $GLOBAL (Recommended learning: PHP programming from entry to proficiency)

$GLOBAL is a super global variable group of PHP that can be accessed in the entire scope of a PHP script.

$GLOBAL is a global combined array containing all variables. The name of the variable is the key of the array.

The following example introduces how to use the super global variable $GLOBAL:

<?php 
$x = 75; 
$y = 25;
  
function addition() 
{ 
$GLOBALS[&#39;z&#39;] = $GLOBALS[&#39;x&#39;] + $GLOBALS[&#39;y&#39;]; 
}
  
addition(); 
echo $z; 
?>

In the above example, z is a super global variable in the $GLOBALS array, which can also be used accessed outside the function.

PHP $_SERVER

$_SERVER is a server that contains information such as header, path, script locations, etc. array. The items in this array are created by the web server. There is no guarantee that every server will offer all items; servers may ignore some, or serve items not listed here.

PHP $_REQUEST

PHP $_REQUEST is used to collect data submitted by HTML forms.

PHP $_POST

PHP $_POST is widely used to collect form data. Specify this attribute in the HTML form tag: "method="post".

PHP $_GET

PHP $_GET is also widely used to collect form data. Specify this attribute in the HTML form tag: "method="get".

$_GET can also collect data sent in the URL.

The above is the detailed content of Are php global variables shared?. 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 Article

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment