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.
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) {
...
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community