3v4l.org

run code in 300+ PHP versions simultaneously
<?php function domainGetFromURL($url, $strip_www = true) { echo print_r(parse_url($url), true); if (!$p = @parse_url($url)) { return ''; } if (strlen($p['host']) == 0) { return ''; } if ($strip_www) { $domain = preg_replace('#^www\.(www\.)*#', '', strtolower($p['host'])); } else { $domain = strtolower($p['host']); } return $domain; } $url = 'domain.ru'; echo domainGetFromURL($url, false);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0buOS
function name:  (null)
number of ops:  7
compiled vars:  !0 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   ASSIGN                                                   !0, 'domain.ru'
   29     1        INIT_FCALL                                               'domaingetfromurl'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <false>
          4        DO_FCALL                                      0  $2      
          5        ECHO                                                     $2
          6      > RETURN                                                   1

Function domaingetfromurl:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 19
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 24
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 36
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0buOS
function name:  domainGetFromURL
number of ops:  43
compiled vars:  !0 = $url, !1 = $strip_www, !2 = $p, !3 = $domain
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <true>
    6     2        INIT_FCALL                                               'print_r'
          3        INIT_FCALL                                               'parse_url'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $4      
          6        SEND_VAR                                                 $4
          7        SEND_VAL                                                 <true>
          8        DO_ICALL                                         $5      
          9        ECHO                                                     $5
    9    10        BEGIN_SILENCE                                    ~6      
         11        INIT_FCALL                                               'parse_url'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $7      
         14        END_SILENCE                                              ~6
         15        ASSIGN                                           ~8      !2, $7
         16        BOOL_NOT                                         ~9      ~8
         17      > JMPZ                                                     ~9, ->19
   10    18    > > RETURN                                                   ''
   13    19    >   FETCH_DIM_R                                      ~10     !2, 'host'
         20        STRLEN                                           ~11     ~10
         21        IS_EQUAL                                                 ~11, 0
         22      > JMPZ                                                     ~12, ->24
   14    23    > > RETURN                                                   ''
   17    24    > > JMPZ                                                     !1, ->36
   18    25    >   INIT_FCALL                                               'preg_replace'
         26        SEND_VAL                                                 '%23%5Ewww%5C.%28www%5C.%29%2A%23'
         27        SEND_VAL                                                 ''
         28        INIT_FCALL                                               'strtolower'
         29        FETCH_DIM_R                                      ~13     !2, 'host'
         30        SEND_VAL                                                 ~13
         31        DO_ICALL                                         $14     
         32        SEND_VAR                                                 $14
         33        DO_ICALL                                         $15     
         34        ASSIGN                                                   !3, $15
         35      > JMP                                                      ->41
   20    36    >   INIT_FCALL                                               'strtolower'
         37        FETCH_DIM_R                                      ~17     !2, 'host'
         38        SEND_VAL                                                 ~17
         39        DO_ICALL                                         $18     
         40        ASSIGN                                                   !3, $18
   23    41    > > RETURN                                                   !3
   24    42*     > RETURN                                                   null

End of function domaingetfromurl

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.33 ms | 1403 KiB | 22 Q