3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function get_domain($url) { if ( !preg_match("/^http/", $url) ) $url = 'http://' . $url; if ( $url[strlen($url)-1] != '/' ) $url .= '/'; $pieces = parse_url($url); $domain = isset($pieces['host']) ? $pieces['host'] : ''; if ( preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs) ) { $res = preg_replace('/^www\./', '', $regs['domain'] ); return $res; } return false; } var_dump(get_domain("mydomain.ua.com"));
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/MWaFk
function name:  (null)
number of ops:  8
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   NOP                                                      
  17     1        INIT_FCALL                                               'var_dump'
         2        INIT_FCALL                                               'get_domain'
         3        SEND_VAL                                                 'mydomain.ua.com'
         4        DO_FCALL                                      0  $0      
         5        SEND_VAR                                                 $0
         6        DO_ICALL                                                 
         7      > RETURN                                                   1

Function get_domain:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
Jump found. Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
Jump found. Position 1 = 21, Position 2 = 24
Branch analysis from position: 21
Jump found. Position 1 = 25
Branch analysis from position: 25
Jump found. Position 1 = 32, Position 2 = 40
Branch analysis from position: 32
Jump found. Position 1 = -2
Branch analysis from position: 40
Jump found. Position 1 = -2
Branch analysis from position: 24
Jump found. Position 1 = 32, Position 2 = 40
Branch analysis from position: 32
Branch analysis from position: 40
Branch analysis from position: 15
Branch analysis from position: 9
filename:       /in/MWaFk
function name:  get_domain
number of ops:  42
compiled vars:  !0 = $url, !1 = $pieces, !2 = $domain, !3 = $regs, !4 = $res
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   RECV                                             !0      
   4     1        INIT_FCALL                                               'preg_match'
         2        SEND_VAL                                                 '%2F%5Ehttp%2F'
         3        SEND_VAR                                                 !0
         4        DO_ICALL                                         $5      
         5        BOOL_NOT                                         ~6      $5
         6      > JMPZ                                                     ~6, ->9
   5     7    >   CONCAT                                           ~7      'http%3A%2F%2F', !0
         8        ASSIGN                                                   !0, ~7
   6     9    >   STRLEN                                           ~9      !0
        10        SUB                                              ~10     ~9, 1
        11        FETCH_DIM_R                                      $11     !0, ~10
        12        IS_NOT_EQUAL                                     ~12     $11, '%2F'
        13      > JMPZ                                                     ~12, ->15
   7    14    >   ASSIGN_CONCAT                                 0          !0, '%2F'
   8    15    >   INIT_FCALL                                               'parse_url'
        16        SEND_VAR                                                 !0
        17        DO_ICALL                                         $14     
        18        ASSIGN                                                   !1, $14
   9    19        ISSET_ISEMPTY_DIM_OBJ                       33554432  ~16     !1, 'host'
        20      > JMPZ                                                     ~16, ->24
        21    >   FETCH_DIM_R                                      $17     !1, 'host'
        22        QM_ASSIGN                                        ~18     $17
        23      > JMP                                                      ->25
        24    >   QM_ASSIGN                                        ~18     ''
        25    >   ASSIGN                                                   !2, ~18
  10    26        INIT_FCALL                                               'preg_match'
        27        SEND_VAL                                                 '%2F%28%3FP%3Cdomain%3E%5Ba-z0-9%5D%5Ba-z0-9%5C-%5D%7B1%2C63%7D%5C.%5Ba-z%5C.%5D%7B2%2C6%7D%29%24%2Fi'
        28        SEND_VAR                                                 !2
        29        SEND_REF                                                 !3
        30        DO_ICALL                                         $20     
        31      > JMPZ                                                     $20, ->40
  11    32    >   INIT_FCALL                                               'preg_replace'
        33        SEND_VAL                                                 '%2F%5Ewww%5C.%2F'
        34        SEND_VAL                                                 ''
        35        FETCH_DIM_R                                      $21     !3, 'domain'
        36        SEND_VAR                                                 $21
        37        DO_ICALL                                         $22     
        38        ASSIGN                                                   !4, $22
  12    39      > RETURN                                                   !4
  14    40    > > RETURN                                                   <false>
  15    41*     > RETURN                                                   null

End of function get_domain

Generated using Vulcan Logic Dumper, using php 7.2.0