IPhoneNumberUtil
in
Tags
Table of Contents
Methods
- convertToStandardFormat() : string|null
- Converts a given input into an E164 formatted phone number
- getCountryCodeForRegion() : int|null
- Returns the country code for a specific region
Methods
convertToStandardFormat()
Converts a given input into an E164 formatted phone number
public
convertToStandardFormat(string $input[, string|null $defaultRegion = null ]) : string|null
E164 is the international format without any formatting characters or spaces. E.g. +41446681800 where +41 is the region code.
Parameters
- $input : string
-
Input phone number can contain formatting spaces, slashes and dashes
- $defaultRegion : string|null = null
-
Two-letter region code of ISO 3166-1
Tags
Return values
string|null —Null when the input is invalid for the given region or requires a region.
getCountryCodeForRegion()
Returns the country code for a specific region
public
getCountryCodeForRegion(string $regionCode) : int|null
For example, this would be 41
for Switzerland and 49
for Germany.
Returns null when the region is invalid.
Parameters
- $regionCode : string
-
Two-letter region code of ISO 3166-1
Tags
Return values
int|null —Null when invalid/unsupported, the phone country code otherwise