summaryrefslogtreecommitdiff
path: root/Zend/tests/constant_expressions_arrays.phpt
blob: 2ab03453de6b810e71976d598ad405444352c4dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
--TEST--
Constant expressions with arrays
--FILE--
<?php
const a = [1,2,[3,[4]]];
const b = a[0];
const c = a[2][0];
const d = a[2];
const e = ["string" => [1]]["string"][0];

var_dump(b, c, e);

function test ($a = d[1][0]) {
	var_dump($a);
}

test();

class foo {
	const bar = [1][0];
}

var_dump(foo::bar);

var_dump(a, a[0], a[2], a[2][1], a[3]);

?>
--EXPECTF--
int(1)
int(3)
int(1)
int(4)
int(1)

Notice: Undefined offset: 3 in %s on line %d
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  array(2) {
    [0]=>
    int(3)
    [1]=>
    array(1) {
      [0]=>
      int(4)
    }
  }
}
int(1)
array(2) {
  [0]=>
  int(3)
  [1]=>
  array(1) {
    [0]=>
    int(4)
  }
}
array(1) {
  [0]=>
  int(4)
}
NULL