Re: [PHP-DEV] make casts more strict in PHP 7

[email protected] (Rowan Collins)
Newsgroups php.internals
Message-ID <[email protected]>
Michael Wallner wrote (on 10/09/2014):
> .oO(ext/filter) ?

Maybe I'm just missing some better documentation, but my main problems 
with ext/filter are:

1) Many users don't know it exists, or how to use it.
2) It's pretty verbose and complex for such a simple task as "is this 
thing a valid integer?"

Basically, it's a swiss army knife, but people are looking for a pair of 
scissors.

There's a lot of code out there doing things like this:

if ( is_numeric($_GET['user_id']) ) {
     display_user($_GET['user_id']);
}

This is definitely the wrong function to use (what kind of a user ID is 
'-1.5e-50'?) but it *looks* like the right function, and it has a really 
simple name, so people don't bother looking for anything more complicated...

-- 
Rowan Collins
[IMSoP]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.