Re: foreach with null

From: Date: Thu, 27 Oct 2005 10:49:57 +0000
Subject: Re: foreach with null
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-19760@lists.php.net to get a copy of this message
Jani Taskinen wrote:
On Thu, 27 Oct 2005, Jochem Maas wrote:
advanced code should be checking vars properly before using them and, well, for any given foreach loop there is often enough an 'if (!count($array))'-like statement to take care of the 'empty' case. and in cases when speed is very important
    ..and where count() magically returns 1 f.e. for FALSE. :)
    So really you can't rely on that. :)
true - although personally I always do if(is_array($r) && count($r)) in such cases. so it seems that there is inconsistency regardless of whether the warning is removed or not. out of interest what are the ramifications for SPL and simpleXML if the warning is not dropped?
    --Jani


« previous php.internals (#19760) next »