Yo, I'm studying and relearning some old PHP basics and I got to superglobals
I don't quite understand why this PHP code is as well as why the superglobal doesn't add to be 15 when logically 10 isn't 15, and help or pointers so I can understand this?
$y = 10;
$x = 5;
$GLOBALS['y'] = $GLOBALS['x'] + $GLOBALS['y'];
I've tried researching this on my own and accepting its because y is just the name of the super global index
none to show other than what's in the question
<?php
$x = 5;
$y = 10;
function myTest() {
$GLOBALS['y'] = $GLOBALS['x'] + $GLOBALS['y'];
}
myTest();
echo $y; // outputs 15
?>
the only error here is my brain
When I look at the code I see $GLOBAL['10'] = $GLOBAL['5'] + $GLOBALS['10'];
I don't understand how 15 can equal 10.