Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- # Trigger bug
- $array = array('a', 'b', 'c', 'd');
- print_r($array); # expected a, b, c, d
- echo '<hr/>';
- foreach ($array as &$a) {}
- print_r($array); # expected a, b, c, d
- echo '<hr/>';
- foreach ($array as $a) {} # <-- this non-reference iteration changes the last item in the array to the second last item.
- print_r($array); # expected a, b, c, d but got a, b, c, c
- die();
- ?>
- <?
- # Does not trigger bug 1
- $array = array('a', 'b', 'c', 'd');
- print_r($array); # expected a, b, c, d
- echo '<hr/>';
- foreach ($array as &$a) {}
- print_r($array); # expected a, b, c, d
- echo '<hr/>';
- foreach ($array as &$a) {}
- print_r($array); # expected a, b, c, d
- die();
- ?>
- <?
- # Does not trigger bug 2
- $array = array('a', 'b', 'c', 'd');
- print_r($array); # expected a, b, c, d
- echo '<hr/>';
- foreach ($array as &$a) {}
- print_r($array); # expected a, b, c, d
- echo '<hr/>';
- print_r($array); # expected a, b, c, d
- die();
- ?>
- <?
- # Does not trigger bug 3
- $array = array('a', 'b', 'c', 'd');
- print_r($array); # expected a, b, c, d
- echo '<hr/>';
- foreach ($array as $a) {}
- print_r($array); # expected a, b, c, d
- echo '<hr/>';
- foreach ($array as $a) {}
- print_r($array); # expected a, b, c, d
- die();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement