PHP is_numeric or preg_match 0-9 validation

前端 未结 11 1588
别跟我提以往
别跟我提以往 2020-12-13 02:48

This isn\'t a big issue for me (as far as I\'m aware), it\'s more of something that\'s interested me. But what is the main difference, if any, of using is_numeric

11条回答
  •  南笙
    南笙 (楼主)
    2020-12-13 03:08

    You can use this code for number validation:

    if (!preg_match("/^[0-9]+$/i", $phone)) {
            $errorMSG = 'Invalid Number!';
            $error    = 1;
        }
    

提交回复
热议问题