Re: foreach with null

From: Date: Tue, 25 Oct 2005 18:51:37 +0000
Subject: Re: foreach with null
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-19722@lists.php.net to get a copy of this message
Hello Christian, Tuesday, October 25, 2005, 7:28:09 PM, you wrote: > Ants Aasma wrote: >> +-0 on the foreach issue, but with the SPL Iterators I can see where >> Marcus is coming from. > Ok, I can see the reason behind it now as casting to array is not an > option for objects with SPL Iterators. One little side-note: Programmers > will still have to do an if($obj) check if they use $obj for just about > anything but foreach. > After thinking it over you convinced me that treating null (and only > null) like an empty array in foreach() might be a good idea, probably > even for the non-SPL case. Hey you two guys pointed out the reason very exactly! Only the usecase wasn't SPL but a potential change i want to do in SimpleXML and the reson SXE behaves like it currently does. But yes SPL and PDO would probably benefit in the same way. Best regards, Marcus

« previous php.internals (#19722) next »