These are things in PHP which make me sad
phpsadness.com
These are things in PHP which make me sad
1–10 of 217 posts
Re: These are things in PHP which make me sad
#2-----
The following things are considered to be empty:
- "" (an empty string)
- [...]
--> "0" (0 as a string) - [...]
- var $var; (a variable declared, but without a value in a class)
-----
Why the heck is "0" considered empty?
Re: These are things in PHP which make me sad
#3Re: These are things in PHP which make me sad
#4This is by far my (least?) favorite: http://ca.php.net/empty ----- The following things are considered to be empty: - "" (an empty string) - [...] --> "0" (0 as a string) - [...] - var $var; (a variable declared, but without a value in a class) ----- Why the heck is "0" considered empty?
making the switch in if() be a boolean only pushes the problem off to the programmer, who will often choose the wrong function or expression to do the conversion
Re: These are things in PHP which make me sad
#5These all seem to be sane critiques of PHP without being all doomsday world-ending inflamatory. Kudos.
Also, I think that this is another example of how hard it is to build up a large and widely-used language/framework without having lots of warts. Especially since PHP wasn't originally designed with the intention of powering everything from a simple blog/cms to facebook.
Re: These are things in PHP which make me sad
#6Re: These are things in PHP which make me sad
#7Re: These are things in PHP which make me sad
#8I've definitely run into #1 on the list. "Paamayim Nekudotayim" is a transliterated version of פעמיים נקודתיים, which means "double colon" in Hebrew. Zeev and Andi are Israeli, which kind of explains it, but the error message is still pretty useless.
Re: These are things in PHP which make me sad
#9php -r 'array("a","b")[0];' results in a parse error.
$xml = getXpathWhatever(); $xml = $xml[0];
Stranger yet, is that it works perfectly fine with resolving objects... for example
$xml = funct()->something->somethingelse()->a
Works fine...
Re: These are things in PHP which make me sad
#10This is by far my (least?) favorite: http://ca.php.net/empty ----- The following things are considered to be empty: - "" (an empty string) - [...] --> "0" (0 as a string) - [...] - var $var; (a variable declared, but without a value in a class) ----- Why the heck is "0" considered empty?
there's something wrong with the == and coercion in the if() statement in any language. making the switch in if() be a boolean only pushes the problem off to the programmer, who will often choose the wrong function or expression to do the conversion
What exactly is the alternative?
If there's any problem here it's automatic coercion.