Support the ongoing development of →
Requests Input
Last updated 9 months ago.

Input values will always be strings. is_int() will fail because of that, regardless if the string value is in integer-format.

I'd advise you utilize Laravel's Validation library to help with this, because you're basically reinventing that wheel.

Last updated 9 months ago.

It turns out, you could do some of these.

$a = '10293';

var_dump(is_int($a)); // false
var_dump(is_numeric($a)); // true
var_dump(preg_match('/\d/', $a) === 1); // true

$b = 'foo';
var_dump(is_int($b)); // false
var_dump(is_numeric($b)); // false
var_dump(preg_match('/\d/', $b) === 1); // false

$c = 10293;
var_dump(is_int($c)); // true
var_dump(is_numeric($c)); // true
var_dump(preg_match('/\d/', $c) === 1); // true

PS: if you just want to make sure the number is a non-zero "number", you could do the following, or you could do as @cryode said, using the Validation Class. :D

if(intval(Input::get('skin')) > 0) { 
Last updated 9 months ago.

Sign in to participate in this thread!


Your banner here too?

Joe96 joe96 Joined 28 Apr 2014


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2023 - All rights reserved.