3v4l.org

run code in 300+ PHP versions simultaneously
<?php //echo is_email('""<script>alert(\'haxxor\')</script>"@domain.com'); echo is_email('"<script>"@domain.com'); function is_email( $email, $deprecated = false ) { if ( ! empty( $deprecated ) ) _deprecated_argument( __FUNCTION__, '3.0' ); // Test for the minimum length the email can be if ( strlen( $email ) < 3 ) { return 'email_too_short' ; } // Test for an @ character after the first position if ( strpos( $email, '@', 1 ) === false ) { return 'email_no_at' ; } // Split out the local and domain parts list( $local, $domain ) = explode( '@', $email, 2 ); // LOCAL PART // Test for invalid characters if ( !preg_match( '/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/', $local ) ) { return 'local_invalid_chars' ; } // DOMAIN PART // Test for sequences of periods if ( preg_match( '/\.{2,}/', $domain ) ) { return 'domain_period_sequence'; } // Test for leading and trailing periods and whitespace if ( trim( $domain, " \t\n\r\0\x0B." ) !== $domain ) { return 'domain_period_limits' ; } // Split the domain into subs $subs = explode( '.', $domain ); // Assume the domain will have at least two subs if ( 2 > count( $subs ) ) { return 'domain_no_periods' ; } // Loop through each sub foreach ( $subs as $sub ) { // Test for leading and trailing hyphens and whitespace if ( trim( $sub, " \t\n\r\0\x0B-" ) !== $sub ) { return'sub_hyphen_limits'; } // Test for invalid characters if ( !preg_match('/^[a-z0-9-]+$/i', $sub ) ) { return 'sub_invalid_chars'; } } // Congratulations your email made it! return 'is_email'; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/flgEJ
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL_BY_NAME                                       'is_email'
          1        SEND_VAL_EX                                              '%22%3Cscript%3E%22%40domain.com'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
   62     4      > RETURN                                                   1

Function is_email:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 21
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 38
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 44
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 50, Position 2 = 51
Branch analysis from position: 50
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 51
2 jumps found. (Code = 43) Position 1 = 59, Position 2 = 60
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 60
2 jumps found. (Code = 77) Position 1 = 61, Position 2 = 79
Branch analysis from position: 61
2 jumps found. (Code = 78) Position 1 = 62, Position 2 = 79
Branch analysis from position: 62
2 jumps found. (Code = 43) Position 1 = 68, Position 2 = 70
Branch analysis from position: 68
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 70
2 jumps found. (Code = 43) Position 1 = 76, Position 2 = 78
Branch analysis from position: 76
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 78
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
Branch analysis from position: 79
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 79
Branch analysis from position: 9
filename:       /in/flgEJ
function name:  is_email
number of ops:  82
compiled vars:  !0 = $email, !1 = $deprecated, !2 = $local, !3 = $domain, !4 = $subs, !5 = $sub
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <false>
    6     2        ISSET_ISEMPTY_CV                                 ~6      !1
          3        BOOL_NOT                                         ~7      ~6
          4      > JMPZ                                                     ~7, ->9
    7     5    >   INIT_FCALL_BY_NAME                                       '_deprecated_argument'
          6        SEND_VAL_EX                                              'is_email'
          7        SEND_VAL_EX                                              '3.0'
          8        DO_FCALL                                      0          
   10     9    >   STRLEN                                           ~9      !0
         10        IS_SMALLER                                               ~9, 3
         11      > JMPZ                                                     ~10, ->13
   11    12    > > RETURN                                                   'email_too_short'
   15    13    >   INIT_FCALL                                               'strpos'
         14        SEND_VAR                                                 !0
         15        SEND_VAL                                                 '%40'
         16        SEND_VAL                                                 1
         17        DO_ICALL                                         $11     
         18        TYPE_CHECK                                    4          $11
         19      > JMPZ                                                     ~12, ->21
   16    20    > > RETURN                                                   'email_no_at'
   20    21    >   INIT_FCALL                                               'explode'
         22        SEND_VAL                                                 '%40'
         23        SEND_VAR                                                 !0
         24        SEND_VAL                                                 2
         25        DO_ICALL                                         $13     
         26        FETCH_LIST_R                                     $14     $13, 0
         27        ASSIGN                                                   !2, $14
         28        FETCH_LIST_R                                     $16     $13, 1
         29        ASSIGN                                                   !3, $16
         30        FREE                                                     $13
   24    31        INIT_FCALL                                               'preg_match'
         32        SEND_VAL                                                 '%2F%5E%5Ba-zA-Z0-9%21%23%24%25%26%27%2A%2B%5C%2F%3D%3F%5E_%60%7B%7C%7D%7E%5C.-%5D%2B%24%2F'
         33        SEND_VAR                                                 !2
         34        DO_ICALL                                         $18     
         35        BOOL_NOT                                         ~19     $18
         36      > JMPZ                                                     ~19, ->38
   25    37    > > RETURN                                                   'local_invalid_chars'
   30    38    >   INIT_FCALL                                               'preg_match'
         39        SEND_VAL                                                 '%2F%5C.%7B2%2C%7D%2F'
         40        SEND_VAR                                                 !3
         41        DO_ICALL                                         $20     
         42      > JMPZ                                                     $20, ->44
   31    43    > > RETURN                                                   'domain_period_sequence'
   35    44    >   INIT_FCALL                                               'trim'
         45        SEND_VAR                                                 !3
         46        SEND_VAL                                                 '+%09%0A%0D%00%0B.'
         47        DO_ICALL                                         $21     
         48        IS_NOT_IDENTICAL                                         !3, $21
         49      > JMPZ                                                     ~22, ->51
   36    50    > > RETURN                                                   'domain_period_limits'
   40    51    >   INIT_FCALL                                               'explode'
         52        SEND_VAL                                                 '.'
         53        SEND_VAR                                                 !3
         54        DO_ICALL                                         $23     
         55        ASSIGN                                                   !4, $23
   43    56        COUNT                                            ~25     !4
         57        IS_SMALLER                                               ~25, 2
         58      > JMPZ                                                     ~26, ->60
   44    59    > > RETURN                                                   'domain_no_periods'
   48    60    > > FE_RESET_R                                       $27     !4, ->79
         61    > > FE_FETCH_R                                               $27, !5, ->79
   50    62    >   INIT_FCALL                                               'trim'
         63        SEND_VAR                                                 !5
         64        SEND_VAL                                                 '+%09%0A%0D%00%0B-'
         65        DO_ICALL                                         $28     
         66        IS_NOT_IDENTICAL                                         !5, $28
         67      > JMPZ                                                     ~29, ->70
   51    68    >   FE_FREE                                                  $27
         69      > RETURN                                                   'sub_hyphen_limits'
   55    70    >   INIT_FCALL                                               'preg_match'
         71        SEND_VAL                                                 '%2F%5E%5Ba-z0-9-%5D%2B%24%2Fi'
         72        SEND_VAR                                                 !5
         73        DO_ICALL                                         $30     
         74        BOOL_NOT                                         ~31     $30
         75      > JMPZ                                                     ~31, ->78
   56    76    >   FE_FREE                                                  $27
         77      > RETURN                                                   'sub_invalid_chars'
   48    78    > > JMP                                                      ->61
         79    >   FE_FREE                                                  $27
   61    80      > RETURN                                                   'is_email'
   62    81*     > RETURN                                                   null

End of function is_email

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.98 ms | 1396 KiB | 21 Q