4 ms·
Just shows me how broken this language is to the core.
by buster 14y ago
Just shows me how broken this language is to the core.
- Zak 14y agoNot that I disagree, but PHP only got exceptions relatively recently. The built-in functions existed long before that. Without exceptions, the options for error handling are to return an error value or exit, writing an error message somewhere. Null seems like an appropriate error value for "you asked for some data formatted as a string, and for whatever reason, I couldn't provide it".
- arde 14y agoI don't think you got to the real problem here. Weak types are quite useful for some tasks, and of course they are nothing new. Languages that convert between integer and string types automatically are well suited for text processing in general (including generating web pages dynamically). The problem with PHP's weak typing is PHP's hit-and-miss implementation. Check out AWK, another weakly typed language, for example: BEGIN{printf "%5.2f\n", ""} prints "0.00" as would be reasonable.