PageRenderTime 48ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/php/semantic/ref_keywordarg.php

https://github.com/llvm-djk/pfff
PHP | 27 lines | 18 code | 7 blank | 2 comment | 0 complexity | d9bbda6e03f8a5b527e7cc66e71a0247 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, LGPL-3.0, ISC
  1. <?php
  2. function taking_a_ref(&$x) {
  3. $x = $x + 10;
  4. }
  5. $x = 0;
  6. taking_a_ref($x = 2);
  7. // output = 2 ... insane
  8. echo $x;
  9. $x = 0;
  10. taking_a_ref($x);
  11. echo $x;
  12. function taking_an_array_ref(&$x) {
  13. $x[] = 'foo';
  14. }
  15. taking_an_array_ref($array = array());
  16. // output is empty array, ... insane
  17. var_dump($array);
  18. $array = array();
  19. taking_an_array_ref($array);
  20. var_dump($array);