Re: Scalar Type Hinting
| From: | Simon Schick | Date: | Thu, 08 Mar 2012 07:39:09 +0000 |
| Subject: | Re: Scalar Type Hinting | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-58766@lists.php.net to get a copy of this message | ||
2012/3/8 John Crenshaw <johncrenshaw@priacta.com>:
>
> Conversion the other way is essential. Consider the following URL:
>
> http://example.com?foo=1
>
> In your PHP script $_GET['foo'] === '1' (a string).
>
> In fact, nearly every input to PHP is a string. This is why PHP was designed with some
> seriously robust type juggling on scalars. Any typing proposal that wants to actually pass a vote is
> going to have to allow appropriate implicit conversions from string to other types.
>
> John Crenshaw
> Priacta, Inc.
Hi, John
Ok .. the example with the get-parameter is quite good.
You'll often have the case that you submit a string "0" or "1" and
want to have it as boolean (f.e. if you have a dropdown with two
options).
Please keep in mind not to mix it up with checkboxes as unchecked
checkboxes won't be sent back to your webserver :)
Bye
Simon