Passing a literal by reference is a Fatal error,
while returning the same literal by reference is a notice.
[#]PHP : Why?
[#]phptip #phptrick
https://php-tips.readthedocs.io/en/latest/tips/by_reference_errors.html
=> More informations about this toot | More toots from dseguy@phpc.social
@dseguy Passing a literal value by reference doesn't make sense and is probably a case of "you are doing it wrong". Think about passing a literal array to sort doesn't make sense....
OTOH returning a reference to some static value still allows me to change that value - even though it might not male much sense.
Alao usually the person calling a function is much more likely to do something stupid than the person writing that function.... 🙈
It might not be the real reason, but it works for me 😁
=> More informations about this toot | More toots from heiglandreas@phpc.social
@heiglandreas @dseguy Passing a literal array to sort() is a common mistake because most people probably expect it to return the sorted array. After 25 years of using sort(), I’ve even found myself doing this and forgetting that it doesn’t return the sorted array.
=> More informations about this toot | More toots from ramsey@phpc.social
@heiglandreas @dseguy A “literal” is a bad example in this case because, if I had a literal, I would probably handwrite it already sorted, but you get the point. 😁
=> More informations about this toot | More toots from ramsey@phpc.social This content has been proxied by September (ba2dc).Proxy Information
text/gemini