3v4l.org

run code in 300+ PHP versions simultaneously
<?php function esip($ip_addr) { //first of all the format of the ip address is matched if(preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$ip_addr)) { //now all the intger values are separated $parts=explode(".",$ip_addr); //now we need to check each part can range from 0-255 foreach($parts as $ip_parts) { if(intval($ip_parts)>255 || intval($ip_parts)<0) return FALSE; //if number is not within range of 0-255 } return TRUE; } else return FALSE; //if format of ip address doesn't matches } function domain($domainb) { $bits = explode('/', $domainb); if ($bits[0]=='http:' || $bits[0]=='https:') { $domainb= $bits[2]; } else { $domainb= $bits[0]; } unset($bits); $bits = explode('.', $domainb); $idz=count($bits); $idz-=3; if (strlen($bits[($idz+2)])==2) { $url=$bits[$idz].'.'.$bits[($idz+1)].'.'.$bits[($idz+2)]; } else if (strlen($bits[($idz+2)])==0) { $url=$bits[($idz)].'.'.$bits[($idz+1)]; } else { $url=$bits[($idz+1)].'.'.$bits[($idz+2)]; } return $url; } $address='clients1.sub3.google.co.uk'; $parsed_url = parse_url($address); $check = esip($parsed_url['host']); $host = $parsed_url['host']; if ($check == FALSE){ if ($host != ""){ $host = domain($host); }else{ $host = domain($address); } } echo $host;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 25
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 21
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/EhD5r
function name:  (null)
number of ops:  27
compiled vars:  !0 = $address, !1 = $parsed_url, !2 = $check, !3 = $host
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   ASSIGN                                                   !0, 'clients1.sub3.google.co.uk'
   47     1        INIT_FCALL                                               'parse_url'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $5      
          4        ASSIGN                                                   !1, $5
   48     5        INIT_FCALL                                               'esip'
          6        FETCH_DIM_R                                      ~7      !1, 'host'
          7        SEND_VAL                                                 ~7
          8        DO_FCALL                                      0  $8      
          9        ASSIGN                                                   !2, $8
   49    10        FETCH_DIM_R                                      ~10     !1, 'host'
         11        ASSIGN                                                   !3, ~10
   50    12        BOOL_NOT                                         ~12     !2
         13      > JMPZ                                                     ~12, ->25
   51    14    >   IS_NOT_EQUAL                                             !3, ''
         15      > JMPZ                                                     ~13, ->21
   52    16    >   INIT_FCALL                                               'domain'
         17        SEND_VAR                                                 !3
         18        DO_FCALL                                      0  $14     
         19        ASSIGN                                                   !3, $14
         20      > JMP                                                      ->25
   54    21    >   INIT_FCALL                                               'domain'
         22        SEND_VAR                                                 !0
         23        DO_FCALL                                      0  $16     
         24        ASSIGN                                                   !3, $16
   57    25    >   ECHO                                                     !3
         26      > RETURN                                                   1

Function esip:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 26
Branch analysis from position: 6
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 23
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 23
Branch analysis from position: 13
2 jumps found. (Code = 47) Position 1 = 16, Position 2 = 19
Branch analysis from position: 16
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
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 19
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EhD5r
function name:  esip
number of ops:  28
compiled vars:  !0 = $ip_addr, !1 = $parts, !2 = $ip_parts
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'preg_match'
          2        SEND_VAL                                                 '%2F%5E%28%5Cd%7B1%2C3%7D%29%5C.%28%5Cd%7B1%2C3%7D%29%5C.%28%5Cd%7B1%2C3%7D%29%5C.%28%5Cd%7B1%2C3%7D%29%24%2F'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $3      
          5      > JMPZ                                                     $3, ->26
    8     6    >   INIT_FCALL                                               'explode'
          7        SEND_VAL                                                 '.'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $4      
         10        ASSIGN                                                   !1, $4
   10    11      > FE_RESET_R                                       $6      !1, ->23
         12    > > FE_FETCH_R                                               $6, !2, ->23
   12    13    >   CAST                                          4  ~7      !2
         14        IS_SMALLER                                       ~8      255, ~7
         15      > JMPNZ_EX                                         ~8      ~8, ->19
         16    >   CAST                                          4  ~9      !2
         17        IS_SMALLER                                       ~10     ~9, 0
         18        BOOL                                             ~8      ~10
         19    > > JMPZ                                                     ~8, ->22
   13    20    >   FE_FREE                                                  $6
         21      > RETURN                                                   <false>
   10    22    > > JMP                                                      ->12
         23    >   FE_FREE                                                  $6
   15    24      > RETURN                                                   <true>
         25*       JMP                                                      ->27
   18    26    > > RETURN                                                   <false>
   19    27*     > RETURN                                                   null

End of function esip

Function domain:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 43
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 62
Branch analysis from position: 62
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 48, Position 2 = 55
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 62
Branch analysis from position: 62
Branch analysis from position: 55
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 43
Branch analysis from position: 32
Branch analysis from position: 43
Branch analysis from position: 12
filename:       /in/EhD5r
function name:  domain
number of ops:  64
compiled vars:  !0 = $domainb, !1 = $bits, !2 = $idz, !3 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
   25     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%2F'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !1, $4
   26     6        FETCH_DIM_R                                      ~6      !1, 0
          7        IS_EQUAL                                         ~7      ~6, 'http%3A'
          8      > JMPNZ_EX                                         ~7      ~7, ->12
          9    >   FETCH_DIM_R                                      ~8      !1, 0
         10        IS_EQUAL                                         ~9      ~8, 'https%3A'
         11        BOOL                                             ~7      ~9
         12    > > JMPZ                                                     ~7, ->16
   28    13    >   FETCH_DIM_R                                      ~10     !1, 2
         14        ASSIGN                                                   !0, ~10
         15      > JMP                                                      ->18
   30    16    >   FETCH_DIM_R                                      ~12     !1, 0
         17        ASSIGN                                                   !0, ~12
   32    18    >   UNSET_CV                                                 !1
   33    19        INIT_FCALL                                               'explode'
         20        SEND_VAL                                                 '.'
         21        SEND_VAR                                                 !0
         22        DO_ICALL                                         $14     
         23        ASSIGN                                                   !1, $14
   34    24        COUNT                                            ~16     !1
         25        ASSIGN                                                   !2, ~16
   35    26        ASSIGN_OP                                     2          !2, 3
   36    27        ADD                                              ~19     !2, 2
         28        FETCH_DIM_R                                      ~20     !1, ~19
         29        STRLEN                                           ~21     ~20
         30        IS_EQUAL                                                 ~21, 2
         31      > JMPZ                                                     ~22, ->43
   37    32    >   FETCH_DIM_R                                      ~23     !1, !2
         33        CONCAT                                           ~24     ~23, '.'
         34        ADD                                              ~25     !2, 1
         35        FETCH_DIM_R                                      ~26     !1, ~25
         36        CONCAT                                           ~27     ~24, ~26
         37        CONCAT                                           ~28     ~27, '.'
         38        ADD                                              ~29     !2, 2
         39        FETCH_DIM_R                                      ~30     !1, ~29
         40        CONCAT                                           ~31     ~28, ~30
         41        ASSIGN                                                   !3, ~31
         42      > JMP                                                      ->62
   38    43    >   ADD                                              ~33     !2, 2
         44        FETCH_DIM_R                                      ~34     !1, ~33
         45        STRLEN                                           ~35     ~34
         46        IS_EQUAL                                                 ~35, 0
         47      > JMPZ                                                     ~36, ->55
   39    48    >   FETCH_DIM_R                                      ~37     !1, !2
         49        CONCAT                                           ~38     ~37, '.'
         50        ADD                                              ~39     !2, 1
         51        FETCH_DIM_R                                      ~40     !1, ~39
         52        CONCAT                                           ~41     ~38, ~40
         53        ASSIGN                                                   !3, ~41
         54      > JMP                                                      ->62
   41    55    >   ADD                                              ~43     !2, 1
         56        FETCH_DIM_R                                      ~44     !1, ~43
         57        CONCAT                                           ~45     ~44, '.'
         58        ADD                                              ~46     !2, 2
         59        FETCH_DIM_R                                      ~47     !1, ~46
         60        CONCAT                                           ~48     ~45, ~47
         61        ASSIGN                                                   !3, ~48
   43    62    > > RETURN                                                   !3
   44    63*     > RETURN                                                   null

End of function domain

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.13 ms | 1411 KiB | 22 Q