Re: Reference handling change and PHP 4.4.0

From: Date: Thu, 15 Sep 2005 03:51:29 +0000
Subject: Re: Reference handling change and PHP 4.4.0
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-18946@lists.php.net to get a copy of this message
Leigh Makewell wrote: > a perfectly legal statement like this $x = current(explode(' ','a b')); In this particular case, current() did not need to take a reference since it doesn't modify anything. This has been fixed in CVS. That's still not how I'd write that though. I would write: list($x) = explode(' ','a b'); Another way to write this: $x = array_shift(explode(' ','a b')); This is where it gets tricky. Is this legal code? We are modifying the argument and immediately discarding the modification. The user might want to know about that, so to me it makes sense that this throws a NOTICE. I do agree with folks who don't like this being a fatal error. I don't think it should be either and this is what we have been discussing. That doesn't change the fact that a lot of these examples are not optimal coding examples. There are usually more direct ways that doesn't involve a useless operation that ends up getting discarded right away. So while the tone of some of these messages may not be great, often the suggestion that the code in question isn't very good is accurate. -Rasmus

« previous php.internals (#18946) next »