SHARE
TWEET

Untitled

a guest Dec 15th, 2011 24 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?
  2. # Trigger bug
  3. $array = array('a', 'b', 'c', 'd');
  4. print_r($array); # expected a, b, c, d
  5. echo '<hr/>';
  6. foreach ($array as &$a) {}
  7. print_r($array); # expected a, b, c, d
  8. echo '<hr/>';
  9. foreach ($array as $a) {} # <-- this non-reference iteration changes the last item in the array to the second last item.
  10. print_r($array); # expected a, b, c, d but got a, b, c, c
  11. die();
  12. ?>
  13.  
  14. <?
  15. # Does not trigger bug 1
  16. $array = array('a', 'b', 'c', 'd');
  17. print_r($array); # expected a, b, c, d
  18. echo '<hr/>';
  19. foreach ($array as &$a) {}
  20. print_r($array); # expected a, b, c, d
  21. echo '<hr/>';
  22. foreach ($array as &$a) {}
  23. print_r($array); # expected a, b, c, d
  24. die();
  25. ?>
  26.  
  27.  
  28. <?
  29. # Does not trigger bug 2
  30. $array = array('a', 'b', 'c', 'd');
  31. print_r($array); # expected a, b, c, d
  32. echo '<hr/>';
  33. foreach ($array as &$a) {}
  34. print_r($array); # expected a, b, c, d
  35. echo '<hr/>';
  36. print_r($array); # expected a, b, c, d
  37. die();
  38. ?>
  39.  
  40.  
  41. <?
  42. # Does not trigger bug 3
  43. $array = array('a', 'b', 'c', 'd');
  44. print_r($array); # expected a, b, c, d
  45. echo '<hr/>';
  46. foreach ($array as $a) {}
  47. print_r($array); # expected a, b, c, d
  48. echo '<hr/>';
  49. foreach ($array as $a) {}
  50. print_r($array); # expected a, b, c, d
  51. die();
  52. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top