PHP program to execute $Globals for sum/ addition of two numbers

A PHP program to execute $Globals for sum/ addition of two numbers. In this program we can declare the globals to execute the program. In PHP, $GLOBALS is a super global variable that allows you to access global variables from anywhere in the script, including functions and methods. In PHP, all global variables are saved in a $GLOBALS[index] array. The name of the variable is saved in the index.

<?php
$a = 4;
$b = 5;
function sum()
{
$GLOBALS['c'] = $GLOBALS['a'] + $GLOBALS['b'];
}
sum();
echo $c;
?>

 

Output:

9