PHP The global Keyword


SUBMITTED BY: henry1874w

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

FORMAT: Text only

SIZE: 130 Bytes

HITS: 240

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

comments powered by Disqus