Re: foreach, assigning to a reference, and E_NOTICE
On Mon, 6 Mar 2006, Sara Golemon wrote:
> > > Can we throw an E_NOTICE when foreach targets a reference? (The other
> > there's many way to use reference, not only in foreach. don't do
> > reference unless u know it's really needed.
> >
> Sean's not so much referring to his own problem as (like you said) the
> solution is a fairly simple matter of following strict coding practices. He's
> trying to address the problem of unexperienced developers seeing this behavior
> and (wrongly) reporting it as a bug, or worse, assuming PHP is just "broken"
> and therefore shouldn't be used.
>
> That said, I'm not convinved this needs a notice, but I'm certainly not
> against it. Perhaps we should split the difference with an E_STRICT.
It *has* to be an E_STRICT because it's something related to language
and possible semantic errors. E_NOTICE is not for that. However, I don't
think that we should add this, as it's perfectly normal and expected
behavior (albeit a bit weird). And indeed, some people might rely on
this "feature".
Derick
Thread (10 messages)