src/bbn/str.php
public static function is_email($email): bool
  {
    if ( function_exists('filter_var') ){
      return filter_var($email,FILTER_VALIDATE_EMAIL) ? true : false;
    }
    else
    {
      $isValid = true;
      $atIndex = mb_strrpos($email, "@");
      if (\is_bool($atIndex) && !$atIndex)
      {
        $isValid = false;
      }
      else
      {
        $domain = mb_substr($email, $atIndex+1);
        $local = mb_substr($email, 0, $atIndex);
        $localLen = mb_strlen($local);
        $domainLen = mb_strlen($domain);
        //  local part length exceeded
        if ($localLen < 1 || $localLen > 64)
          $isValid = false;
        //  domain part length exceeded
        else if ($domainLen < 1 || $domainLen > 255)
          $isValid = false;
        // local part starts or ends with '.'
        else if ($local[0] == '.' || $local[$localLen-1] == '.')
          $isValid = false;
        // local part has two consecutive dots
        else if (mb_ereg_match('\\.\\.', $local))
          $isValid = false;
        // character not valid in domain part
        else if (!mb_ereg_match('^[A-Za-z0-9\\-\\.]+$', $domain))
          $isValid = false;
        //  domain part has two consecutive dots
        else if (mb_ereg_match('\\.\\.', $domain))
          $isValid = false;
        //  character not valid in local part unless
        else if ( !mb_ereg_match('^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$'
          ,str_replace("\\\\","",$local)))
        {
          // local part is quoted
          if ( !mb_ereg_match('^"(\\\\"|[^"])+"$',str_replace("\\\\","",$local)) )
            $isValid = false;
        }
      }
      return $isValid;
    }
  }
public static function is_email($email): bool
  {
    if ( function_exists('filter_var') ){
      return filter_var($email,FILTER_VALIDATE_EMAIL) ? true : false;
    }
    else
    {
      $isValid = true;
      $atIndex = mb_strrpos($email, "@");
      if (\is_bool($atIndex) && !$atIndex)
      {
        $isValid = false;
      }
      else
      {
        $domain = mb_substr($email, $atIndex+1);
        $local = mb_substr($email, 0, $atIndex);
        $localLen = mb_strlen($local);
        $domainLen = mb_strlen($domain);
        //  local part length exceeded
        if ($localLen < 1 || $localLen > 64)
          $isValid = false;
        //  domain part length exceeded
        else if ($domainLen < 1 || $domainLen > 255)
          $isValid = false;
        // local part starts or ends with '.'
        else if ($local[0] == '.' || $local[$localLen-1] == '.')
          $isValid = false;
        // local part has two consecutive dots
        else if (mb_ereg_match('\\.\\.', $local))
          $isValid = false;
        // character not valid in domain part
        else if (!mb_ereg_match('^[A-Za-z0-9\\-\\.]+$', $domain))
          $isValid = false;
        //  domain part has two consecutive dots
        else if (mb_ereg_match('\\.\\.', $domain))
          $isValid = false;
        //  character not valid in local part unless
        else if ( !mb_ereg_match('^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$'
          ,str_replace("\\\\","",$local)))
        {
          // local part is quoted
          if ( !mb_ereg_match('^"(\\\\"|[^"])+"$',str_replace("\\\\","",$local)) )
            $isValid = false;
        }
      }
      return $isValid;
    }
  }
public static function is_email ( $ email ) : bool { if ( function_exists ( 'filter_var' ) ) { return filter_var ( $ email , FILTER_VALIDATE_EMAIL ) ? true : false ; } else { $ isValid = true ; $ atIndex = mb_strrpos ( $ email , "@" ) ; if ( \ is_bool ( $ atIndex ) && ! $ atIndex ) { $ isValid = false ; } else { $ domain = mb_substr ( $ email , $ atIndex + 1 ) ; $ local = mb_substr ( $ email , 0 , $ atIndex ) ; $ localLen = mb_strlen ( $ local ) ; $ domainLen = mb_strlen ( $ domain ) ; //  local part length exceeded if ( $ localLen < 1 || $ localLen > 64 ) $ isValid = false ; //  domain part length exceeded else if ( $ domainLen < 1 || $ domainLen > 255 ) $ isValid = false ; // local part starts or ends with '.' else if ( $ local [ 0 ] == '.' || $ local [ $ localLen - 1 ] == '.' ) $ isValid = false ; // local part has two consecutive dots else if ( mb_ereg_match ( '\\.\\.' , $ local ) ) $ isValid = false ; // character not valid in domain part else if ( ! mb_ereg_match ( '^[A-Za-z0-9\\-\\.]+$' , $ domain ) ) $ isValid = false ; //  domain part has two consecutive dots else if ( mb_ereg_match ( '\\.\\.' , $ domain ) ) $ isValid = false ; //  character not valid in local part unless else if ( ! mb_ereg_match ( '^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$' , str_replace ( "\\\\" , "" , $ local ) ) ) { // local part is quoted if ( ! mb_ereg_match ( '^"(\\\\"|[^"])+"$' , str_replace ( "\\\\" , "" , $ local ) ) ) $ isValid = false ; } } return $ isValid ; } }
Checks if the string is the correct type of e-mail address.

```php
\bbn\x::dump(\bbn\str::is_email('test@email.com'));
// (bool) true
\bbn\x::dump(\bbn\str::is_email('test@email'));
// (bool) false
\bbn\x::dump(\bbn\str::is_email('test@.com'));
// (bool) false
\bbn\x::dump(\bbn\str::is_email('testemail.com'));
// (bool) false
```

@param string $email E-mail address.
@return bool
Checks if the string is the correct type of e - mail address .