elabuwa Posted October 6, 2009 Share Posted October 6, 2009 Hey guys, Probably one of the easiest questions ever asked. What is the function you use to validate if a variable is numeric is or not. This function must treat values with decimals as numbers. I tried is_numeric, c_type(digit) or some thing like that with no luck. I tried this below code found in the net. If (validate_numeric($total_received)){ echo "Please Enter A Numeric Value For The Total Received"; exit; } I ended up getting the below error. Fatal error: Call to undefined function validate_numeric() in C:\wamp\www\myacc\receipts\process.php on line 47 So i thought that there is an easier already built in function that im missing. can you please help me out. thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/176689-solved-php-number-validation/ Share on other sites More sharing options...
Jahren Posted October 6, 2009 Share Posted October 6, 2009 if(is_numeric($IThinkItsANumber)) //bla What is the error with is_numeric? reference: http://us3.php.net/manual/en/function.is-numeric.php Quote Link to comment https://forums.phpfreaks.com/topic/176689-solved-php-number-validation/#findComment-931514 Share on other sites More sharing options...
KevinM1 Posted October 6, 2009 Share Posted October 6, 2009 Moreover, like your error states, there is no such function as validate_numeric() in PHP. For simple things like this, looking at the manual (http://www.php.net/quickref.php) is the best place to start. Quote Link to comment https://forums.phpfreaks.com/topic/176689-solved-php-number-validation/#findComment-931519 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.