Courses Job Ready Program Fresher Trainings AI For Class 7 to 12 Corporate Training Placements Tutorials
Free Learning Resources

IT Tutorials & Interview Prep

Free guides, interview Q&As, and job responsibility breakdowns — curated by industry veterans to help you crack MNC interviews

166+
Tutorial Articles
8
Topic Categories
100%
Free to Read
← Back to PHP

$GLOBALS

PHP Last Updated: Oct 17, 2025

$GLOBALS

$GLOBALS is a superglobal variable, which is also an array that stores all the global scope variables and is used to access global variables from anywhere in the PHP program.

Example:

<?php
$x = 10;
$y = 11;

function add() {
 $GLOBALS['z'] = $GLOBALS['x'] + $GLOBALS['y'];
}

add();
echo $z;
?>

Output:

21