Re: foreach with null

From: Date: Tue, 25 Oct 2005 16:52:06 +0000
Subject: Re: foreach with null
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-19720@lists.php.net to get a copy of this message
Antony Dovgal wrote:
On 25.10.2005 19:39, Ants Aasma wrote:
It currently is equal: $ php -r 'var_dump(null == array()); var_dump((array) null);' bool(true) array(0) { }
No, there aren't equal. Use === and you'll see the difference.
At least the manual says that the == operator is named equal and the === operator is named identical. Actually I wanted to point out that null is a bit of a special case in PHP: $ php -r 'var_dump(null == 0); var_dump(null == array()); var_dump(0 == array());' bool(true) bool(true) bool(false) $ php -r 'var_dump((array) ""); var_dump((array) 0); var_dump((array) null);' array(1) { [0]=> string(0) "" } array(1) { [0]=> int(0) } array(0) { } +-0 on the foreach issue, but with the SPL Iterators I can see where Marcus is coming from. Ants

« previous php.internals (#19720) next »