3v4l.org

run code in 300+ PHP versions simultaneously
<?php function format_url($url) { if(parse_url($url, PHP_URL_SCHEME) === null) { $url = 'http://' . $url; //parse_url() requires scheme to parse URL correctly } $parsed_url = parse_url($url); $formatted_url = get_domain($parsed_url['host'], false); if (isset($parsed_url['path'])) { $formatted_url .= $parsed_url['path']; } if (isset($parsed_url['query'])) { $formatted_url .= '?' . $parsed_url['query']; } $formatted_url = rtrim($formatted_url, '/'); return $formatted_url; } $url = 'http://www.igrushka-spb.ru/index.php?categoryID=1718'; var_dump(format_url($url));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JV7RU
function name:  (null)
number of ops:  8
compiled vars:  !0 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   ASSIGN                                                   !0, 'http%3A%2F%2Fwww.igrushka-spb.ru%2Findex.php%3FcategoryID%3D1718'
   27     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'format_url'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function format_url:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 24
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 29
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
Branch analysis from position: 24
Branch analysis from position: 9
filename:       /in/JV7RU
function name:  format_url
number of ops:  36
compiled vars:  !0 = $url, !1 = $parsed_url, !2 = $formatted_url
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                                                 0
          4        DO_ICALL                                         $3      
          5        TYPE_CHECK                                    2          $3
          6      > JMPZ                                                     ~4, ->9
    5     7    >   CONCAT                                           ~5      'http%3A%2F%2F', !0
          8        ASSIGN                                                   !0, ~5
    8     9    >   INIT_FCALL                                               'parse_url'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $7      
         12        ASSIGN                                                   !1, $7
   10    13        INIT_FCALL_BY_NAME                                       'get_domain'
         14        CHECK_FUNC_ARG                                           
         15        FETCH_DIM_FUNC_ARG                               $9      !1, 'host'
         16        SEND_FUNC_ARG                                            $9
         17        SEND_VAL_EX                                              <false>
         18        DO_FCALL                                      0  $10     
         19        ASSIGN                                                   !2, $10
   12    20        ISSET_ISEMPTY_DIM_OBJ                         0          !1, 'path'
         21      > JMPZ                                                     ~12, ->24
   13    22    >   FETCH_DIM_R                                      ~13     !1, 'path'
         23        ASSIGN_OP                                     8          !2, ~13
   16    24    >   ISSET_ISEMPTY_DIM_OBJ                         0          !1, 'query'
         25      > JMPZ                                                     ~15, ->29
   17    26    >   FETCH_DIM_R                                      ~16     !1, 'query'
         27        CONCAT                                           ~17     '%3F', ~16
         28        ASSIGN_OP                                     8          !2, ~17
   20    29    >   INIT_FCALL                                               'rtrim'
         30        SEND_VAR                                                 !2
         31        SEND_VAL                                                 '%2F'
         32        DO_ICALL                                         $19     
         33        ASSIGN                                                   !2, $19
   22    34      > RETURN                                                   !2
   23    35*     > RETURN                                                   null

End of function format_url

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.62 ms | 1394 KiB | 20 Q