WC_Validation::is_phone( string $phone )

Validates a phone number using a regular expression.


Description Description


Parameters Parameters

$phone

(Required) Phone number to validate.


Top ↑

Return Return

(bool)


Top ↑

Source Source

File: includes/class-wc-validation.php

32
33
34
35
36
37
38
public static function is_phone( $phone ) {
    if ( 0 < strlen( trim( preg_replace( '/[\s\#0-9_\-\+\/\(\)\.]/', '', $phone ) ) ) ) {
        return false;
    }
 
    return true;
}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.