fork download
  1. <?php
  2.  
  3. function delta($prefix, $t1) {
  4. $t2 = microtime(true);
  5. printf("%s %0.6f\n", $prefix, ($t2 - $t1) * 1000);
  6. }
  7.  
  8. function genarray() {
  9. $a = array();
  10. for($i = 0; $i < 10000; $i++) {
  11. $a[] = $i;
  12. }
  13. return($a);
  14. }
  15.  
  16. function noref($a) {
  17. for($i = 0; $i < 10000; $i++) {
  18. is_array($a);
  19. }
  20. }
  21.  
  22. function byref($a) {
  23. for($i = 0; $i < 10000; $i++) {
  24. is_array(&$a);
  25. }
  26. }
  27.  
  28. $a = genarray();
  29. $t1 = microtime(true);
  30. noref($a);
  31. delta("NoRef:", $t1);
  32.  
  33. $t3 = microtime(true);
  34. byref($a);
  35. delta("ByRef:", $t3);
Runtime error #stdin #stdout #stderr 0.01s 20520KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Fatal error:  Call-time pass-by-reference has been removed in /home/LHHrI9/prog.php on line 24