File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / Zend / tests / bug60362.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 12:34:36 2012 UTC (13 years, 7 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, HEAD
php 5.4.3+patches

    1: --TEST--
    2: Bug #60362: non-existent sub-sub keys should not have values
    3: --FILE--
    4: <?php
    5: $arr = array('exists' => 'foz');
    6: 
    7: if (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: }
   13: if (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: 
   20: echo "-------------------\n";
   21: if (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: }
   27: if (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: 
   34: echo "-------------------\n";
   35: if (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: }
   41: if (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: 
   48: echo "-------------------\n";
   49: if (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: }
   55: if (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: }
   61: echo "DONE";
   62: --EXPECT--
   63: sub-key 'non_existent' is not set.
   64: sub-key 1 is set: string(1) "o"
   65: -------------------
   66: sub-sub-key 'sub_sub' is not set.
   67: sub-sub-key 0 is set: string(1) "o"
   68: -------------------
   69: sub-key 'non_existent' is empty.
   70: sub-key 1 is not empty: string(1) "o"
   71: -------------------
   72: sub-sub-key 'sub_sub' is empty.
   73: sub-sub-key 0 is not empty: string(1) "o"
   74: DONE

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>