3v4l.org

run code in 300+ PHP versions simultaneously
<?php $email = 'johnsnow123@ヒキワリ.ナットウ.fr'; $email = 'johnsnow123@foo.bar.zoosk.fr'; $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 = 10, Position 2 = 12
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 48, Position 2 = 50
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 50
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YQ95V
function name:  (null)
number of ops:  52
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.fr'
    4     1        ASSIGN                                                   !0, 'johnsnow123%40foo.bar.zoosk.fr'
    6     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '%40'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $9      
          6        ASSIGN                                                   !1, $9
    7     7        COUNT                                            ~11     !1
          8        IS_NOT_IDENTICAL                                         ~11, 2
          9      > JMPZ                                                     ~12, ->12
    8    10    >   ECHO                                                     'invalid'
    9    11      > RETURN                                                   null
   12    12    >   FETCH_DIM_R                                      ~13     !1, 0
         13        ASSIGN                                                   !2, ~13
   13    14        ASSIGN                                                   !3, '%5E%5Ba-z0-9_-%5D%2B%28%3F%3A%5Ba-z0-9._%25%2B-%5D%2B%29%2A%24'
   14    15        INIT_FCALL                                               'mb_eregi'
         16        SEND_VAR                                                 !3
         17        SEND_VAR                                                 !2
         18        DO_ICALL                                         $16     
         19        TYPE_CHECK                                    4          $16
         20      > JMPZ                                                     ~17, ->23
   15    21    >   ECHO                                                     'invalid'
   16    22      > RETURN                                                   null
   20    23    >   FETCH_DIM_R                                      ~18     !1, 1
         24        ASSIGN                                                   !4, ~18
   21    25        INIT_FCALL                                               'str_replace'
         26        SEND_VAL                                                 'xn--'
         27        SEND_VAL                                                 ''
         28        INIT_FCALL_BY_NAME                                       'idn_to_ascii'
         29        SEND_VAR_EX                                              !4
         30        DO_FCALL                                      0  $20     
         31        SEND_VAR                                                 $20
         32        DO_ICALL                                         $21     
         33        ASSIGN                                                   !4, $21
   23    34        ASSIGN                                                   !5, <array>
   24    35        INIT_FCALL                                               'implode'
         36        SEND_VAL                                                 '%7C'
         37        SEND_VAR                                                 !5
         38        DO_ICALL                                         $24     
         39        CONCAT                                           ~25     '%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', $24
         40        CONCAT                                           ~26     ~25, '%29%24'
         41        ASSIGN                                                   !6, ~26
   26    42        INIT_FCALL                                               'mb_eregi'
         43        SEND_VAR                                                 !6
         44        SEND_VAR                                                 !4
         45        DO_ICALL                                         $28     
         46        TYPE_CHECK                                    4          $28
         47      > JMPZ                                                     ~29, ->50
   27    48    >   ECHO                                                     'invalid'
   28    49      > RETURN                                                   null
   31    50    >   ECHO                                                     'valid'
         51      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.15 ms | 1400 KiB | 21 Q