valid.phpt 761 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. --TEST--
  2. Supported operations on $GLOBALS
  3. --FILE--
  4. <?php
  5. function test() {
  6. var_dump($GLOBALS['x']);
  7. $GLOBALS['x'] = 1;
  8. var_dump($GLOBALS['x']);
  9. $GLOBALS['x']++;
  10. var_dump($GLOBALS['x']);
  11. $GLOBALS['x'] += 2;
  12. var_dump($GLOBALS['x']);
  13. unset($GLOBALS['y']);
  14. var_dump(isset($GLOBALS['x']));
  15. var_dump(isset($GLOBALS['y']));
  16. $GLOBALS['z'][] = 1;
  17. }
  18. $y = 1;
  19. test();
  20. var_dump($x, $y, $z);
  21. $ref = 1;
  22. $GLOBALS['z'] =& $ref;
  23. $ref++;
  24. var_dump($z);
  25. $x = 1;
  26. $ref2 =& $GLOBALS['x'];
  27. $ref2++;
  28. var_dump($x);
  29. ?>
  30. --EXPECTF--
  31. Warning: Undefined global variable $x in %s on line %d
  32. NULL
  33. int(1)
  34. int(2)
  35. int(4)
  36. bool(true)
  37. bool(false)
  38. Warning: Undefined variable $y in %s on line %d
  39. int(4)
  40. NULL
  41. array(1) {
  42. [0]=>
  43. int(1)
  44. }
  45. int(2)
  46. int(2)