Changes to PHP 4.4.0 which breaks backwards compatibility
There is a change with references which breaks backwards compatibility in version of PHP >= 4.4.0.
Many people seem, including myself, at times have incorrectly used references in code similar to John's code below:
$b = false;
return empty($a) ? $b : $a;
According to resident PHP guru Derick Rethans, "this is actually correct behavior. The ?: operator creates a copy and the you returning by reference doesn't work of course." On his blog he also wrote:
Through Planet PHP I saw the blog entry "Is PHP staying the language I want to work with?", for with comments are cowardly disabled. Although the way classes are handled is debatable, moaning that PHP 4.4 breaks "return ($ret)" when returning by reference only shows that the programmer has had no clue about references in the first place. If you place () around a variable, you're making it an expression. You can only return variables by references, not expressions. The return-by-reference in this function never could have worked as it should have in the first place. Clue: Don't use "return (
Derick also has a article in the June 2005 issue of php|architect where he explains what references are in more detail.
The PHP Manual is a bit misleading about returning references on the return() function page but on the returning values page it shows one should be returning references without using the ()'s as part of the call to return.