0
Php
$GLOBALS is a PHP super global variable which is used to access global variables from anywhere in the PHP script (also from within functions or methods). PHP stores all global variables in an array called $GLOBALS[index]. The index holds the name of the variable. <?php $x = 75; $y = 25; function addition() { $GLOBALS['z'] = $GLOBALS['x'] + $GLOBALS['y']; } addition(); echo $z; ?>
2 Réponses
+ 21
So, what is your question?
0
This is an another way to use global variable
<?php
$x = 75;
$y = 25;
function addition() {
global $z,$y,$x;
$z = $x + $y;
}
addition();
echo $z;
?>