I came across the following situation. I have a string and I have to validate its value. That way, I have to check if it's integer. So I will have to pass the string to number and check if it is integer or float.
I thought of something like this:
if((int)"13.1" == 13.1){
echo "certo";
}
The problem is whether digital or true is true.
if((int)"true" == "true"){
echo "certo";
}
It is still possible, the person passing non-string value. How do I validate in this case. I need to accept only integer, but many times I will receive this value in string, and I can receive in boolean or float ... How to validate in this situation?
1 = true
1.1 = false
true = false
"ss" = false