I’d like to validate $_POST’s contain, that must be number. How can i check out $_POST’s contain with PHP?
for example (what i want as the result):
1876 //true
2.34 // false
erfka // false
1djs33 // false
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
ctype_digit is your friend. It checks that only digits are contained in the variable, not periods or anything other. ctype_digit doesn’t even allow negative numbers, but just digits.
It actually also checks that there is a number contained. The empty string is evaluated to
falsewith ctype_digit.