end_variation3.phpt 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. --TEST--
  2. Test end() function : usage variations - Referenced variables
  3. --FILE--
  4. <?php
  5. /* Prototype : mixed end(array $array_arg)
  6. * Description: Advances array argument's internal pointer to the last element and return it
  7. * Source code: ext/standard/array.c
  8. */
  9. /*
  10. * Test how the internal pointer is affected when two variables are referenced to each other
  11. */
  12. echo "*** Testing end() : usage variations ***\n";
  13. $array1 = array ('zero', 'one', 'two');
  14. echo "\n-- Initial position of internal pointer --\n";
  15. var_dump(current($array1));
  16. end($array1);
  17. // Test that when two variables are referenced to one another
  18. // the internal pointer is the same for both
  19. $array2 = &$array1;
  20. echo "\n-- Position after calling end() --\n";
  21. echo "\$array1: ";
  22. var_dump(current($array1));
  23. echo "\$array2: ";
  24. var_dump(current($array2));
  25. ?>
  26. ===DONE===
  27. --EXPECTF--
  28. *** Testing end() : usage variations ***
  29. -- Initial position of internal pointer --
  30. string(4) "zero"
  31. -- Position after calling end() --
  32. $array1: string(3) "two"
  33. $array2: string(3) "two"
  34. ===DONE===