>
>
> Now strings. There are two different kinds of strings.
> The first one $age = $_POST['age'] is the kind of string that you want to
> treat as a number. And that's fine.
>
> But you also have $name = $_POST['name'] // 'John Doe' which is wrong
> to treat as a the same as $age.
>
>
php doesn't have the necessary information to tell whether your input
variable is a number, or only looks like a number.
how would you define what is an int? what type would the following input
variables have?
- "1"
- "1.1"
- "1.0"
- ".5"
- "0777"

I think it is better to populate everything as string, and let the
application developer to parse the inputs as he knows what should they
represent.

Btw. there was a discussion about raising a warning (somebody even
suggested creating an E_TYPE level) when data loss occurs on a type
juggling.
I would support that, as people tend to be surprised when they realize the
first time that 123 == '123 apples' evaluates to true in php.

-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu

Reply via email to