- var_dump: documentation ( source)
- is_numeric: documentation ( source)
<?php
foreach([null, '', '0', 'abc', '1', '01', '0.1', '1.5'] as $val) {
var_dump($val);
var_dump(is_numeric($val));
if ((int) $val) {
var_dump(1);
} elseif ($val) {
var_dump(2);
} else {
var_dump(3);
}
}