end_variation3.phpt 848 B

12345678910111213141516171819202122232425262728293031323334
  1. --TEST--
  2. Test end() function : usage variations - Referenced variables
  3. --FILE--
  4. <?php
  5. /*
  6. * Test how the internal pointer is affected when two variables are referenced to each other
  7. */
  8. echo "*** Testing end() : usage variations ***\n";
  9. $array1 = array ('zero', 'one', 'two');
  10. echo "\n-- Initial position of internal pointer --\n";
  11. var_dump(current($array1));
  12. end($array1);
  13. // Test that when two variables are referenced to one another
  14. // the internal pointer is the same for both
  15. $array2 = &$array1;
  16. echo "\n-- Position after calling end() --\n";
  17. echo "\$array1: ";
  18. var_dump(current($array1));
  19. echo "\$array2: ";
  20. var_dump(current($array2));
  21. ?>
  22. --EXPECT--
  23. *** Testing end() : usage variations ***
  24. -- Initial position of internal pointer --
  25. string(4) "zero"
  26. -- Position after calling end() --
  27. $array1: string(3) "two"
  28. $array2: string(3) "two"