Validate phone number

Chek if a phone numbers is valid, according to its syntax (should be: "+390523599314"). True if it's valid, False otherwise

function is_valid_phone( $phone ) 
{
   if ( $phone[0] != "+" ) {
      return false;
   } // end if
   else {
      $phone = substr( $phone, 1 ); // delete the "+"
      if ( !is_numeric( $phone ) ) {
         return false;
      } // end if
   } // end else
   return true;
} // end function is_valid_phone

Tags

No tag here.

Recommended pages

Detect file extension function...

This function is used to find the file extension also you can use pathinfo() function for get information about a file path. function ext($file_name) { return substr($file_name, strrpos($fi...

Resize image function...

Resize image function for jpg format. $mood between max and min. if you choose max, this mean max size of image is $ta otherwise min size of image is $ta. function makeTheThumb( $ppath, $ta, $mood ) ...

How to created mixed arguments function...

This way useful for create mixed arguments function. function foo() { $args = func_get_args(); print_r($args); }   foo(1, 1256, 6, 17); //mixed ...   -------------------Out-...

URL Checker...

This function check if an url is valid or not. function is_valid_url($url) { return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url); }...