diff options
author | Stanislav Malyshev <stas@php.net> | 2011-12-19 02:05:03 +0000 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2011-12-19 02:05:03 +0000 |
commit | 1f4f33afcfd8282bcdeff9ebcee7aade8c659308 (patch) | |
tree | 379c71b1166f89859baba1bc4c1aaba54e17c01c /Zend/tests/bug60362.phpt | |
parent | 61f3d36ac16a092cade99691bf3a16b2532468c7 (diff) | |
download | php-git-1f4f33afcfd8282bcdeff9ebcee7aade8c659308.tar.gz |
implement the solution for isset/string offsets, fix bug #60362
Diffstat (limited to 'Zend/tests/bug60362.phpt')
-rw-r--r-- | Zend/tests/bug60362.phpt | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/Zend/tests/bug60362.phpt b/Zend/tests/bug60362.phpt new file mode 100644 index 0000000000..e8d16ea4cb --- /dev/null +++ b/Zend/tests/bug60362.phpt @@ -0,0 +1,74 @@ +--TEST-- +Bug #60362: non-existent sub-sub keys should not have values +--FILE-- +<?php +$arr = array('exists' => 'foz'); + +if (isset($arr['exists']['non_existent'])) { + echo "sub-key 'non_existent' is set: "; + var_dump($arr['exists']['non_existent']); +} else { + echo "sub-key 'non_existent' is not set.\n"; +} +if (isset($arr['exists'][1])) { + echo "sub-key 1 is set: "; + var_dump($arr['exists'][1]); +} else { + echo "sub-key 1 is not set.\n"; +} + +echo "-------------------\n"; +if (isset($arr['exists']['non_existent']['sub_sub'])) { + echo "sub-key 'sub_sub' is set: "; + var_dump($arr['exists']['non_existent']['sub_sub']); +} else { + echo "sub-sub-key 'sub_sub' is not set.\n"; +} +if (isset($arr['exists'][1][0])) { + echo "sub-sub-key 0 is set: "; + var_dump($arr['exists'][1][0]); +} else { + echo "sub-sub-key 0 is not set.\n"; +} + +echo "-------------------\n"; +if (empty($arr['exists']['non_existent'])) { + echo "sub-key 'non_existent' is empty.\n"; +} else { + echo "sub-key 'non_existent' is not empty: "; + var_dump($arr['exists']['non_existent']); +} +if (empty($arr['exists'][1])) { + echo "sub-key 1 is empty.\n"; +} else { + echo "sub-key 1 is not empty: "; + var_dump($arr['exists'][1]); +} + +echo "-------------------\n"; +if (empty($arr['exists']['non_existent']['sub_sub'])) { + echo "sub-sub-key 'sub_sub' is empty.\n"; +} else { + echo "sub-sub-key 'sub_sub' is not empty: "; + var_dump($arr['exists']['non_existent']['sub_sub']); +} +if (empty($arr['exists'][1][0])) { + echo "sub-sub-key 0 is empty.\n"; +} else { + echo "sub-sub-key 0 is not empty: "; + var_dump($arr['exists'][1][0]); +} +echo "DONE"; +--EXPECT-- +sub-key 'non_existent' is not set. +sub-key 1 is set: string(1) "o" +------------------- +sub-sub-key 'sub_sub' is not set. +sub-sub-key 0 is set: string(1) "o" +------------------- +sub-key 'non_existent' is empty. +sub-key 1 is not empty: string(1) "o" +------------------- +sub-sub-key 'sub_sub' is empty. +sub-sub-key 0 is not empty: string(1) "o" +DONE |