In fact, all the values โโof $ _REQUEST (as well as $ _GET, $ _POST, etc.) are always strings .
When $qty is $_REQUEST[qty] , it is a string, not an integer. When $qty is 1 , it is already an integer.
Use the intval function to convert it to an integer. But, as you say, you want to know if it is an integer or not, so use floatval to convert it, and then check if they are equal:
if (intval($qty) == floatval($qty)) { echo "Ok!"; } else { echo "error"; }
source share