1--TEST-- 2Constant arrays 3--INI-- 4zend.enable_gc=1 5--FILE-- 6<?php 7 8define('FOOBAR', [1, 2, 3, ['foo' => 'bar']]); 9const FOO_BAR = [1, 2, 3, ['foo' => 'bar']]; 10 11$x = FOOBAR; 12$x[0] = 7; 13var_dump($x, FOOBAR); 14 15$x = FOO_BAR; 16$x[0] = 7; 17var_dump($x, FOO_BAR); 18 19// ensure references are removed 20$x = 7; 21$y = [&$x]; 22define('QUX', $y); 23$y[0] = 3; 24var_dump($x, $y, QUX); 25 26// ensure objects not allowed in arrays 27var_dump(define('ELEPHPANT', [new StdClass])); 28 29// ensure recursion doesn't crash 30$recursive = []; 31$recursive[0] = &$recursive; 32var_dump(define('RECURSION', $recursive)); 33--EXPECTF-- 34array(4) { 35 [0]=> 36 int(7) 37 [1]=> 38 int(2) 39 [2]=> 40 int(3) 41 [3]=> 42 array(1) { 43 ["foo"]=> 44 string(3) "bar" 45 } 46} 47array(4) { 48 [0]=> 49 int(1) 50 [1]=> 51 int(2) 52 [2]=> 53 int(3) 54 [3]=> 55 array(1) { 56 ["foo"]=> 57 string(3) "bar" 58 } 59} 60array(4) { 61 [0]=> 62 int(7) 63 [1]=> 64 int(2) 65 [2]=> 66 int(3) 67 [3]=> 68 array(1) { 69 ["foo"]=> 70 string(3) "bar" 71 } 72} 73array(4) { 74 [0]=> 75 int(1) 76 [1]=> 77 int(2) 78 [2]=> 79 int(3) 80 [3]=> 81 array(1) { 82 ["foo"]=> 83 string(3) "bar" 84 } 85} 86int(3) 87array(1) { 88 [0]=> 89 &int(3) 90} 91array(1) { 92 [0]=> 93 int(7) 94} 95 96Warning: Constants may only evaluate to scalar values, arrays or resources in %s on line %d 97bool(false) 98 99Warning: Constants cannot be recursive arrays in %s on line %d 100bool(false) 101