3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_domain($url){ $host = parse_url( $url, PHP_URL_HOST ); $host_parts = explode(".", $host); if(count($host_parts)>2){ array_shift($host_parts); } return implode(".", $host_parts); } assert( get_domain("http://eye-talk.org/") == "eye-talk.org" ); assert( get_domain("http://www.eye-talk.org/") == "eye-talk.org" ); assert( get_domain("http://www.eye-talk.org.cc/") == "eye-talk.org.cc" );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5phlS
function name:  (null)
number of ops:  28
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ASSERT_CHECK                                             
          1        INIT_FCALL                                               'assert'
          2        INIT_FCALL                                               'get_domain'
          3        SEND_VAL                                                 'http%3A%2F%2Feye-talk.org%2F'
          4        DO_FCALL                                      0  $0      
          5        IS_EQUAL                                         ~1      $0, 'eye-talk.org'
          6        SEND_VAL                                                 ~1
          7        SEND_VAL                                                 'assert%28get_domain%28%27http%3A%2F%2Feye-talk.org%2F%27%29+%3D%3D+%27eye-talk.org%27%29'
          8        DO_ICALL                                                 
   13     9        ASSERT_CHECK                                             
         10        INIT_FCALL                                               'assert'
         11        INIT_FCALL                                               'get_domain'
         12        SEND_VAL                                                 'http%3A%2F%2Fwww.eye-talk.org%2F'
         13        DO_FCALL                                      0  $3      
         14        IS_EQUAL                                         ~4      $3, 'eye-talk.org'
         15        SEND_VAL                                                 ~4
         16        SEND_VAL                                                 'assert%28get_domain%28%27http%3A%2F%2Fwww.eye-talk.org%2F%27%29+%3D%3D+%27eye-talk.org%27%29'
         17        DO_ICALL                                                 
   14    18        ASSERT_CHECK                                             
         19        INIT_FCALL                                               'assert'
         20        INIT_FCALL                                               'get_domain'
         21        SEND_VAL                                                 'http%3A%2F%2Fwww.eye-talk.org.cc%2F'
         22        DO_FCALL                                      0  $6      
         23        IS_EQUAL                                         ~7      $6, 'eye-talk.org.cc'
         24        SEND_VAL                                                 ~7
         25        SEND_VAL                                                 'assert%28get_domain%28%27http%3A%2F%2Fwww.eye-talk.org.cc%2F%27%29+%3D%3D+%27eye-talk.org.cc%27%29'
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Function get_domain:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 17
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/5phlS
function name:  get_domain
number of ops:  23
compiled vars:  !0 = $url, !1 = $host, !2 = $host_parts
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'parse_url'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 1
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !1, $3
    5     6        INIT_FCALL                                               'explode'
          7        SEND_VAL                                                 '.'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $5      
         10        ASSIGN                                                   !2, $5
    6    11        COUNT                                            ~7      !2
         12        IS_SMALLER                                               2, ~7
         13      > JMPZ                                                     ~8, ->17
    7    14    >   INIT_FCALL                                               'array_shift'
         15        SEND_REF                                                 !2
         16        DO_ICALL                                                 
    9    17    >   INIT_FCALL                                               'implode'
         18        SEND_VAL                                                 '.'
         19        SEND_VAR                                                 !2
         20        DO_ICALL                                         $10     
         21      > RETURN                                                   $10
   11    22*     > RETURN                                                   null

End of function get_domain

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.06 ms | 1394 KiB | 26 Q