Annotation of embedaddon/php/ext/standard/tests/array/compact_variation1.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test compact() function : usage variations - arrays containing references.
! 3: --FILE--
! 4: <?php
! 5: /* Prototype : proto array compact(mixed var_names [, mixed ...])
! 6: * Description: Creates a hash containing variables and their values
! 7: * Source code: ext/standard/array.c
! 8: * Alias to functions:
! 9: */
! 10: /*
! 11: * compact variations - arrays with references
! 12: */
! 13: echo "*** Testing compact() : usage variations - arrays containg references ***\n";
! 14: $a = 1;
! 15: $b = 2;
! 16: $c = 3;
! 17: $string = "c";
! 18: $arr1 = array("a", &$arr1);
! 19: $arr2 = array("a", array(array(array("b"))));
! 20: $arr2[1][0][0][] = &$arr2;
! 21: $arr2[1][0][0][] = &$arr2[1];
! 22: $arr3 = array(&$string);
! 23: var_dump(compact($arr1));
! 24: var_dump(compact($arr2));
! 25: var_dump(compact($arr3));
! 26: echo "Done";
! 27: ?>
! 28: --EXPECTF--
! 29: *** Testing compact() : usage variations - arrays containg references ***
! 30:
! 31: Warning: compact(): recursion detected in %s on line %d
! 32: array(1) {
! 33: ["a"]=>
! 34: int(1)
! 35: }
! 36:
! 37: Warning: compact(): recursion detected in %s on line %d
! 38:
! 39: Warning: compact(): recursion detected in %s on line %d
! 40:
! 41: Warning: compact(): recursion detected in %s on line %d
! 42:
! 43: Warning: compact(): recursion detected in %s on line %d
! 44: array(2) {
! 45: ["a"]=>
! 46: int(1)
! 47: ["b"]=>
! 48: int(2)
! 49: }
! 50: array(1) {
! 51: ["c"]=>
! 52: int(3)
! 53: }
! 54: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>