Re: foreach with null

From: Date: Mon, 24 Oct 2005 22:56:53 +0000
Subject: Re: foreach with null
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-19712@lists.php.net to get a copy of this message
Marcus Boerger wrote:
i would like to change foreach a tiny bit. Actually i don't like the warning when using foreach with null. The way we use NULL in PHP should result in no warning here. The patch for
Can you elaborate on the "The way we use NULL in PHP" part? IMPW (In my PHP world) null represents an undefined variable. Trying to iterate over it could be a programming mistake. Like iterating over a scalar value. I normally use foreach ((array)$var as $value) if $var is of "mixed" type which also catches null. But most of the time I'm more comfortable with making sure I provide a real array in all cases and don't rely on magic. Just my two cents, - Chris

« previous php.internals (#19712) next »