PHP global keyword
global keyword is used to access global variables within a function.
To call a global variable defined outside a function within a function, we need to add global before the variable in the function Keywords:
Instance
<?php
$x=5;
$y=10;
fun ction myTest()
{
global $x,$y;
$y=$x $y;
}
myTest();
echo $y; // Output 15
?>
Output 15 here should be output 10, myTest() cannot output here, you should add an echo $y
Okay thanks for the feedback!