function str_ends_with ( $haystack , $needle ) check_email( $email )

<?php
//check_email.php

if ( !( function_exists ( 'str_starts_with' ) ) ){
 function str_starts_with ( $haystack , $needle ) {
 return substr_compare ( $haystack , $needle , 0 , strlen ( $needle ) ) === 0 ; 
 }
}

if (!( function_exists ( 'str_ends_with' ) )) {
 function str_ends_with ( $haystack , $needle ) {
 return substr_compare ( $haystack , $needle , - strlen ( $needle ) ) === 0 ;
 }
}

//Check if input email is Company email address 
function  check_email( $email )
{
    $email=strtolower($email);
    if( str_ends_with( $email , '@126.com' ) || str_ends_with( $email , '@163.com' ))
    {
        return true;
    }
    else
    {
        return false;
    }
}

 

posted @ 2018-03-13 10:01  sky20080101  阅读(165)  评论(0)    收藏  举报