closure_019.phpt 580 B

1234567891011121314151617181920212223242526272829
  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: Cannot pass parameter 1 by reference in %s on line %d