Re: foreach, assigning to a reference, and E_NOTICE

From: Date: Tue, 07 Mar 2006 07:41:36 +0000
Subject: Re: foreach, assigning to a reference, and E_NOTICE
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Sean Coates wrote:
it's not the problem of the second foreach, any usage of $j after the 1st foreach as &$j will hurt
Yes. I thought it was clear that I understand this. I guess not. My point is that foreach is doing something that isn't immediately obvious. The same is true of your for loop, but to a lesser extent, IMO (as I don't expect your for loop to ONLY read from $i). I don't want to start a discussion on references. I'm just trying to clear up a non-obvious case.
How would you supress the notice (I know error suppression is ugly), but we need to make it possible for people to quickly adapt to this change if they indeed relied on this. would this work: foreach ($i as @&$j) {} regards, Lukas

Thread (10 messages)

« previous php.internals (#22167) next »