NYCPHP Meetup

NYPHP.org

[nycphp-talk] Extracting an int from a query string.

Rob Marscher rmarscher at beaffinitive.com
Wed Nov 14 13:04:50 EST 2007


On Nov 13, 2007, at 3:14 PM, John Campbell wrote:
> On Nov 13, 2007 2:56 PM, dann <dann at bentobox.net> wrote:
>> One small caveat I failed to mention earlier: [...snip...]  
>> ctype_digit [...snip...] returns false
>> if you pass it an actual integer.
> Easily fixed with:
> ctype_digit("$int");
> With the added bonus, that another dev will come behind you, remove
> the quotes, and create a bug. :)

Although, you originally said you were using this for request  
variables which are always strings.

By the way, I've been seeing rumors on the web that the ternary  
operator will support this syntax in PHP6:

$assigned = isset($somevar) ?: 'default';

Even less typing!




More information about the talk mailing list