Annotation of embedaddon/php/ext/standard/tests/array/array_values_variation6.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test array_values() function : usage variations - Referenced variables
                      3: --INI--
                      4: allow_call_time_pass_reference=on
                      5: --FILE--
                      6: <?php
                      7: /* Prototype  : array array_values(array $input)
                      8:  * Description: Return just the values from the input array 
                      9:  * Source code: ext/standard/array.c
                     10:  */
                     11: 
                     12: /*
                     13:  * Test array_values() when:
                     14:  * 1. Passed an array made up of referenced variables
                     15:  * 2. Passed an array by reference
                     16:  */
                     17: 
                     18: echo "*** Testing array_values() : usage variations ***\n";
                     19: 
                     20: $val1 = 'one';
                     21: $val2 = 'two';
                     22: $val3 = 'three';
                     23: 
                     24: echo "\n-- \$input is an array made up of referenced variables: --\n";
                     25: $input = array(&$val1, &$val2, &$val3);
                     26: var_dump($result1 = array_values($input));
                     27: 
                     28: echo "Change \$val2 and check result of array_values():\n";
                     29: $val2 = 'deux';
                     30: var_dump($result1);
                     31: 
                     32: echo "\n-- Pass \$input argument by reference --\n";
                     33: $array = array(1, 2, 3);
                     34: var_dump($result2 = array_values(&$array));
                     35: 
                     36: echo "Done";
                     37: ?>
                     38: 
                     39: --EXPECTF--
                     40: *** Testing array_values() : usage variations ***
                     41: 
                     42: -- $input is an array made up of referenced variables: --
                     43: array(3) {
                     44:   [0]=>
                     45:   &string(3) "one"
                     46:   [1]=>
                     47:   &string(3) "two"
                     48:   [2]=>
                     49:   &string(5) "three"
                     50: }
                     51: Change $val2 and check result of array_values():
                     52: array(3) {
                     53:   [0]=>
                     54:   &string(3) "one"
                     55:   [1]=>
                     56:   &string(4) "deux"
                     57:   [2]=>
                     58:   &string(5) "three"
                     59: }
                     60: 
                     61: -- Pass $input argument by reference --
                     62: array(3) {
                     63:   [0]=>
                     64:   int(1)
                     65:   [1]=>
                     66:   int(2)
                     67:   [2]=>
                     68:   int(3)
                     69: }
                     70: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>