Jump to content

Recommended Posts

I made a function which makes sure all numbers entered only contain the characters 0-9 but for some reason if you enter random numbers it returns false

 

function validno($var) {

if(!is_numeric($var)) {

$ret = 0;

} elseif($var < 0) {

$ret = 0;

} elseif(!preg_match('/^[0-9]+$/', $var)) {

$ret = 0;

} else {

$ret = 1;

}

return $ret;

}

 

It returns false if you enter 12000000000, 14000000000, 17000000000 that I'm aware of. Probably more but I'm not sure. Any see the problem? Thanks

Link to comment
https://forums.phpfreaks.com/topic/177310-solved-problem-with-number-verification/
Share on other sites

I just realised it wasn't in that function :P it was in the script. I'm not sure why but 12000000000 was converted to 1.2E+10 and when I used intval to get the value I saw intval has a limit of 2147483647

 

If anyone knows any other functions I'd really appreciate you helping me

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.