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

Change timestamp to custom format...

Use this function for change timestamp to custom format......

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); }...

Best way to get user ip address in php...

Here is a function to getting ip using filter of local and lan ip's. function get_ip() { $list = array( 'REMOTE_ADDR', 'CLIENT_IP', 'HTTP_CLIENT_IP', 'HTTP_PROXY_CONNECTION',...

Detect leap year...

Detect leap year for gregorian and shamsi date. function gLeapYear($year) { if (($year % 4 == 0) and (($year % 100 != 0) or ($year % 400 == 0))) return true; else return ...