closure_019.phpt 695 B

123456789101112131415161718192021222324252627282930313233
  1. --TEST--
  2. Closure 019: Calling lambda using $GLOBALS and global $var
  3. --FILE--
  4. <?php
  5. $lambda = function &(&$x) {
  6. return $x = $x * $x;
  7. };
  8. function test() {
  9. global $lambda;
  10. $y = 3;
  11. var_dump($GLOBALS['lambda']($y));
  12. var_dump($lambda($y));
  13. var_dump($GLOBALS['lambda'](1));
  14. }
  15. test();
  16. ?>
  17. --EXPECTF--
  18. Notice: Only variable references should be returned by reference in %sclosure_019.php on line 4
  19. int(9)
  20. Notice: Only variable references should be returned by reference in %sclosure_019.php on line 4
  21. int(81)
  22. Fatal error: Uncaught Error: {closure}(): Argument #1 ($x) cannot be passed by reference in %s:%d
  23. Stack trace:
  24. #0 %s(%d): test()
  25. #1 {main}
  26. thrown in %s on line %d