|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-03-11 05:17 UTC] laruence@php.net
Description:
------------
isset(arrayobject['index']) act inconsistently with isset(array['index'])
Test script:
---------------
<?php
$a = array('b' => NULL);
var_dump(isset($a['b']));
$b = new ArrayObject($a);
var_dump(isset($b['b']));
Expected result:
----------------
bool(false)
bool(false)
Actual result:
--------------
bool(false)
bool(true)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 06:00:01 2025 UTC |
these codes are weired(spl_array.c:603): switch(Z_TYPE_P(offset)) { case IS_STRING: if (check_empty) { if (zend_symtable_find(spl_array_get_hash_table(intern, 0 TSRMLS_CC), Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void **) &tmp) != FAILURE) { switch (check_empty) { case 0: return Z_TYPE_PP(tmp) != IS_NULL; case 2: return 1; default: return zend_is_true(*tmp); } } return 0; } else { return zend_symtable_exists(spl_array_get_hash_table(intern, 0 TSRMLS_CC), Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1); } note the switch statement, there is no chance check_empty will be 0, since there is a if(check_empty) before. and, I don't see any chance that the check_empty could be 2. any idea? thanksone more : $a = array('b' => "test"); $b = new ArrayObject($a); var_dump(isset($b->b)); outputed : bool(false) should this be true?