3v4l.org

run code in 300+ PHP versions simultaneously
<?php $email = 'johnsnow123@ヒキワリ.ナットウ.com'; $localAndDomain = explode('@', $email); if (count($localAndDomain) !== 2) { echo 'invalid'; return; } $local = $localAndDomain[0]; $localExpression = '^[a-z0-9_-]+(?:[a-z0-9._%+-]+)*$'; if (mb_eregi($localExpression, $local) === false) { echo 'invalid'; return; } // Handle IDN domains $domain = $localAndDomain[1]; $domain = str_replace('xn--', '', idn_to_ascii($domain)); $dictionary = array('aero', 'arpa', 'asia', 'biz', 'cat', 'com', 'coop', 'edu', 'gov', 'info', 'int', 'jobs', 'mil', 'mobi', 'museum', 'name', 'net', 'org', 'pro', 'tel', 'travel'); $domainExpression = '^(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+(?:[A-Z]{2}|' . implode('|', $dictionary) . ')$'; if (mb_eregi($domainExpression, $domain) === false) { echo 'invalid'; return; } echo 'valid';
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 49
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KZrHk
function name:  (null)
number of ops:  51
compiled vars:  !0 = $email, !1 = $localAndDomain, !2 = $local, !3 = $localExpression, !4 = $domain, !5 = $dictionary, !6 = $domainExpression
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'johnsnow123%40%E3%83%92%E3%82%AD%E3%83%AF%E3%83%AA.%E3%83%8A%E3%83%83%E3%83%88%E3%82%A6.com'
    5     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%40'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $8      
          5        ASSIGN                                                   !1, $8
    6     6        COUNT                                            ~10     !1
          7        IS_NOT_IDENTICAL                                         ~10, 2
          8      > JMPZ                                                     ~11, ->11
    7     9    >   ECHO                                                     'invalid'
    8    10      > RETURN                                                   null
   11    11    >   FETCH_DIM_R                                      ~12     !1, 0
         12        ASSIGN                                                   !2, ~12
   12    13        ASSIGN                                                   !3, '%5E%5Ba-z0-9_-%5D%2B%28%3F%3A%5Ba-z0-9._%25%2B-%5D%2B%29%2A%24'
   13    14        INIT_FCALL                                               'mb_eregi'
         15        SEND_VAR                                                 !3
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                         $15     
         18        TYPE_CHECK                                    4          $15
         19      > JMPZ                                                     ~16, ->22
   14    20    >   ECHO                                                     'invalid'
   15    21      > RETURN                                                   null
   19    22    >   FETCH_DIM_R                                      ~17     !1, 1
         23        ASSIGN                                                   !4, ~17
   20    24        INIT_FCALL                                               'str_replace'
         25        SEND_VAL                                                 'xn--'
         26        SEND_VAL                                                 ''
         27        INIT_FCALL_BY_NAME                                       'idn_to_ascii'
         28        SEND_VAR_EX                                              !4
         29        DO_FCALL                                      0  $19     
         30        SEND_VAR                                                 $19
         31        DO_ICALL                                         $20     
         32        ASSIGN                                                   !4, $20
   22    33        ASSIGN                                                   !5, <array>
   23    34        INIT_FCALL                                               'implode'
         35        SEND_VAL                                                 '%7C'
         36        SEND_VAR                                                 !5
         37        DO_ICALL                                         $23     
         38        CONCAT                                           ~24     '%5E%28%3F%3A%5Ba-z0-9%5D%28%3F%3A%5Ba-z0-9-%5D%2A%5Ba-z0-9%5D%29%3F%5C.%29%2B%28%3F%3A%5BA-Z%5D%7B2%7D%7C', $23
         39        CONCAT                                           ~25     ~24, '%29%24'
         40        ASSIGN                                                   !6, ~25
   25    41        INIT_FCALL                                               'mb_eregi'
         42        SEND_VAR                                                 !6
         43        SEND_VAR                                                 !4
         44        DO_ICALL                                         $27     
         45        TYPE_CHECK                                    4          $27
         46      > JMPZ                                                     ~28, ->49
   26    47    >   ECHO                                                     'invalid'
   27    48      > RETURN                                                   null
   30    49    >   ECHO                                                     'valid'
         50      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.39 ms | 1400 KiB | 21 Q