Posted inJavaScript / jQuery / php

how to validate mobile number in php?

how to validate mobile number in php – Php Validate Phone Number using pattern, Regular Expression Mobile Number Validation in PHP.

$phone = '000-0000-0000';

if(preg_match("/^[0-9]{3}-[0-9]{4}-[0-9]{4}$/", $phone)) {
  // $phone is valid
}

how to validate mobile number in php?

Mobile valid pattern

$mob="/^[1-9][0-9]*$/"; 

How to validate phone number in PHP?

Example

function validate_phone_number($phone)
{

     $filtered_phone_number = filter_var($phone, FILTER_SANITIZE_NUMBER_INT);

     $phone_to_check = str_replace("-", "", $filtered_phone_number);

     if (strlen($phone_to_check) < 10 || strlen($phone_to_check) > 14) {
        return false;
     } else {
       return true;
     }
}

how to validate phone number in php procedural programming?

Example

if((preg_match("/[^0-9]/", '', $str)) && strlen($str) == 10)
{
echo "Invalid phone number
}

Mobile number validation pattern in PHP

index.php


How To Validation Phone Number Using PHP?

I hope you get an idea about how to validate mobile number in php.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype