Tuesday, August 6, 2013

Where does PHP store global variables?

PHP stores all global variables in an array called $GLOBALS[index].

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

$GLOBALS['y']=$GLOBALS['x']+$GLOBALS['y']; //Same as "$y = $x + $y;"

echo $y;
?>

No comments :