PHP $GLOBALS[index] array
HP also stores all global variables in an array called $GLOBALS[index]. The index holds the name of the variable. This array is also accessible from within functions and can be used to update global variables directly.
<?php
  $x = 70;
  $y = 7;

  function myNum {
    $GLOBALS['y'] = $GLOBALS['x'] + $GLOBALS['y'];
  }
  
  myNum();
  echo $y; // output is 77
?>
by Tornike Kartvelishvili
2 years ago
PHP
Variables
Variables Scope
0
Pro tip: use ```triple backticks around text``` to write in code fences