Re: invalid array key/index not generating notices

php.internals

Sara Golemon

19 years ago
> I came across a subtle bug a developer introduced into our > application. It took us a month to realize the bug was > there because PHP didn't throw a notice. >
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_execute.c?revision=1.755&view=markup Down inside zend_fetch_dimension_address(), you'll find this block: switch(Z_TYPE_P(container)) { /* ... */ case IS_NULL: { /* for read-mode only */ if (result) { result->var.ptr_ptr = &EG(uninitialized_zval_ptr); PZVAL_LOCK(*result->var.ptr_ptr); } if (type==BP_VAR_W || type==BP_VAR_RW) { zend_error(E_WARNING, "Cannot use a NULL value as an array"); } break; } /* ... */ } To me, that screams intentional, and since BC trumps reason, this isn't going to change. -Sara