xref: /php-src/Zend/tests/bug60362.phpt (revision 7aacc705)
1--TEST--
2Bug #60362: non-existent sub-sub keys should not have values
3--FILE--
4<?php
5$arr = array('exists' => 'foz');
6
7if (isset($arr['exists']['non_existent'])) {
8    echo "sub-key 'non_existent' is set: ";
9    var_dump($arr['exists']['non_existent']);
10} else {
11    echo "sub-key 'non_existent' is not set.\n";
12}
13if (isset($arr['exists'][1])) {
14    echo "sub-key 1 is set: ";
15    var_dump($arr['exists'][1]);
16} else {
17    echo "sub-key 1 is not set.\n";
18}
19
20echo "-------------------\n";
21if (isset($arr['exists']['non_existent']['sub_sub'])) {
22    echo "sub-key 'sub_sub' is set: ";
23    var_dump($arr['exists']['non_existent']['sub_sub']);
24} else {
25    echo "sub-sub-key 'sub_sub' is not set.\n";
26}
27if (isset($arr['exists'][1][0])) {
28    echo "sub-sub-key 0 is set: ";
29    var_dump($arr['exists'][1][0]);
30} else {
31    echo "sub-sub-key 0 is not set.\n";
32}
33
34echo "-------------------\n";
35if (empty($arr['exists']['non_existent'])) {
36    echo "sub-key 'non_existent' is empty.\n";
37} else {
38    echo "sub-key 'non_existent' is not empty: ";
39    var_dump($arr['exists']['non_existent']);
40}
41if (empty($arr['exists'][1])) {
42    echo "sub-key 1 is empty.\n";
43} else {
44    echo "sub-key 1 is not empty: ";
45    var_dump($arr['exists'][1]);
46}
47
48echo "-------------------\n";
49if (empty($arr['exists']['non_existent']['sub_sub'])) {
50    echo "sub-sub-key 'sub_sub' is empty.\n";
51} else {
52    echo "sub-sub-key 'sub_sub' is not empty: ";
53    var_dump($arr['exists']['non_existent']['sub_sub']);
54}
55if (empty($arr['exists'][1][0])) {
56    echo "sub-sub-key 0 is empty.\n";
57} else {
58    echo "sub-sub-key 0 is not empty: ";
59    var_dump($arr['exists'][1][0]);
60}
61echo "DONE";
62?>
63--EXPECT--
64sub-key 'non_existent' is not set.
65sub-key 1 is set: string(1) "o"
66-------------------
67sub-sub-key 'sub_sub' is not set.
68sub-sub-key 0 is set: string(1) "o"
69-------------------
70sub-key 'non_existent' is empty.
71sub-key 1 is not empty: string(1) "o"
72-------------------
73sub-sub-key 'sub_sub' is empty.
74sub-sub-key 0 is not empty: string(1) "o"
75DONE
76