Hey guys hopefully this is just a quick question.
I've a form that is sending data to a PHP script. The form has the following textbox:
<input id="quantity1" name="quantity1" type="text" value="" />
Whenever it is posted I do the following:
function isInteger($val) {
if (is_int($val)) {
return true;
} else {
return false;
}
}
$test = $_POST["quantity1"];
echo gettype($test); // Which is returning as a string
if ( isInteger($test) ) {
echo "<p>It's an integer!</p>";
} else {
echo "<p>It's not an integer!</p>";
}
Even if I type a number such as '1' or '123' into the textbox, it's always being picked up by the script as string type. Is there anyway to convert this into an integer, or even hardcoding the $test variable to be strictly an integer?
Thanks in advance,
Anthony