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


SUBMITTED BY: henry1874w

DATE: June 4, 2017, 7:59 p.m.

FORMAT: Text only

SIZE: 144 Bytes

HITS: 300

  1. <?php
  2. $x = 5;
  3. $y = 10;
  4. function myTest() {
  5. $GLOBALS['y'] = $GLOBALS['x'] + $GLOBALS['y'];
  6. }
  7. myTest();
  8. echo $y; // outputs 15
  9. ?>

comments powered by Disqus