[KLUG Members] PHP strict.
Adam Williams
members@kalamazoolinux.org
04 Aug 2002 17:07:57 -0400
>Not really. Different philosophy at work to accomplish a different goal.
Exactly. PHP ain't C, never will be. Appropriate tools for the
correct jobs. It is easy to summon C routine via XML-RPC or some other
messaging API. There is even a CORBA extension these days.
>You can set the error level high if you want to flag uninitialized values, but
>realize it doesn't make sense to fix the variable type in advance in an
>environment where you can't define in advance the value (string, integer, float,
>etc.) of a field on an HTML form. There is no <input type=integer> in html.
>Old word processors had no spell check before printing, HTTP has no type check
>before submitting a form.. The user sends all their data all at once, then the
>server (with your programming) processes it and replies.
Right, sine HTTP doesn't support types it would be pretty ugly for a
HTTP scripting language to try to do so. Although it would be a nice
option to be able to flip on in certain cases. But then without
exceptions type error handling would be a real drag. And PHP
***STINKS*** at real data-processing anyway.
>You can check the type once it arrives and is assigned to a variable, and then
>your code should reply back to the browser with a new html reply that the error
>needs correction.
Yes, but don't rely on their type routines too heavily; they are
pretty sloppy about what they consider what.
>ithin HTTP there's no way to check individual fields without submitting the
>ntire document, and there's no way to reply to individual errors except with
>another whole document. There's no HTTP error code that means "whoops, that
>value is the wrong type." Even if there was, the form (and it's values) would
>be history already. You may use javascript or other client scripts to check
>before submission, but that, again, is outside PHP because it is outside HTTP.
Exactly.
>Variable typing is just one way of checking values. Learn to test the values
>you're working with before you use them and you'll develop more robust code and
>you'll find it will work pretty smooth.
>>Wow ... that is pretty disturbing.
You van at least declare variable names if you use oo classes.