Re: Type hinting

From: Date: Thu, 03 Jun 2010 20:24:28 +0000
Subject: Re: Type hinting
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  Groups: php.internals 
Request: Send a blank email to internals+get-48628@lists.php.net to get a copy of this message
On Thu, 03 Jun 2010 17:25:53 +0100, Josh Davis <phpwnd@gmail.com> wrote:
On 1 June 2010 20:43, Stas Malyshev <smalyshev@sugarcrm.com> wrote:
It is very frequent that you want number and get "1" instead - almost all incoming data for PHP are strings.
I'd like to point out that filter_input() does cast user input to the right PHP type. And if memory serves, ext/filter is meant to be PHP's standard way of handling user input. So in terms of incoming data, I'd consider user input being covered already. The only other big source of data is the database. [...]
User input and databases are certainly not the only sources of incoming data – think for instance about (possibly already dtd/schema validated) XML. Another example with dates: $d1 = new DateTime("2010-06-01"); $d2 = new DateTime("2010-07-01"); my_func($d1->format("w")); my_func2($d2->diff($d1)->format("%d")); I'm sure it wouldn't be hard to find other examples outside form submissions and databases. -- Gustavo Lopes

« previous php.internals (#48628) next »