4 ms·
Not for user-provided input. That's just a dumb thing to do in any language.
by methodin 14y ago
Not for user-provided input. That's just a dumb thing to do in any language.
- masklinn 14y ago> Not for user-provided input. Not what for user-provided input? The source of a string does not matter to this rule of PHP: a string used in numeric context will be parsed and converted, if it can not be parsed as a number its numeric value will be 0. That's it. That's how the language defines strings in numeric contexts. > That's just a dumb thing to do in any language. Sure, you won't get any argument from me on that, but that remains how PHP works and has always worked.
- TylerE 14y agoProbably. But then again, we're talking about a language where THIS happens: php> echo "2coolforschool" + 1; 3 php> echo "2.1coolforschool" + 1; 3.1 php> echo "coolforschool" + 1; 1 So treating all kinds of garbage as valid numbers is absolutely part of PHP.
- piggity 14y agoThat's just the general design philosophy of the MP components of the LAMP stack. Do the stupidest thing that could possibly work; and it probably will. For now.