Re: [RFC] Safe Casting Functions
| From: | Andrea Faulds | Date: | Wed, 22 Oct 2014 21:41:51 +0000 |
| Subject: | Re: [RFC] Safe Casting Functions | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-78251@lists.php.net to get a copy of this message | ||
> On 22 Oct 2014, at 22:31, Stas Malyshev <smalyshev@sugarcrm.com> wrote:
>
> Hi!
>
>> Are you opposed to the existence of ext/filter given it has
>> FILTER_VALIDATE_INT, a “primitive for handling type conversions”?
>
> FILTER_VALIDATE_INT is an option for a filter_var function, and it is
> not introducing any new rules for handling types in the engine.
Nor is this.
> What you are proposing is not like FILTER_VALIDATE_INT, it's like (int).
I don’t see the difference:
$x = filter_var(FILTER_VALIDATE_INT, $foo);
$x = to_int($foo);
They’re very similar, except the latter has slightly different rules, is shorter, and if some
people (possibly me) get their way, might throw an exception.
--
Andrea Faulds
http://ajf.me/