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;  ?>

15th Mar 2018, 5:48 AM
Ahamed Saja
Ahamed Saja - avatar
2 Réponses
+ 21
So, what is your question?
15th Mar 2018, 6:19 AM
Igor Makarsky
Igor Makarsky - avatar
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; ?>
15th Mar 2018, 11:05 AM
caheamt
caheamt - avatar