3v4l.org

run code in 500+ PHP versions simultaneously
<?php $values = [ 'ip' => '127.0.0.1', 'hostname' => 'localhost', 'ipport' => '127.0.0.1:3307', 'hostname' => 'localhost:3308', 'ipv6' => '[2001:0DB8::1234]', 'ipv6port' => '[2001:0DB8::1234]:3309', ]; foreach($values as $k=>$hostport) { $host = 'not found'; $port = 'not found'; // has port or ipv6 if (strpos($hostport, ':')) { // ipv6 if (str_starts_with($hostport, '[')) { $portposition = strpos($hostport,']:'); if ($portposition) { $port = substr($hostport, $portposition+2); $host = substr($hostport, 0, $portposition+1); } else { $host = $hostport; } } else { [$host, $port] = explode(':', $hostport); } } else { $host = $hostport; // ipv4/domainname without port } echo $k .': Hostname: ' . $host . ' Port: ' . $port ."\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 41
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 41
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 33
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 23
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 21
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
filename:       /in/oFFaE
function name:  (null)
number of ops:  43
compiled vars:  !0 = $values, !1 = $hostport, !2 = $k, !3 = $host, !4 = $port, !5 = $portposition
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   12     1      > FE_RESET_R                                           $7      !0, ->41
          2    > > FE_FETCH_R                                           ~8      $7, !1, ->41
          3    >   ASSIGN                                                       !2, ~8
   13     4        ASSIGN                                                       !3, 'not+found'
   14     5        ASSIGN                                                       !4, 'not+found'
   17     6        FRAMELESS_ICALL_2                strpos              ~12     !1, '%3A'
          7      > JMPZ                                                         ~12, ->33
   19     8    >   FRAMELESS_ICALL_2                str_starts_with      ~13     !1, '%5B'
          9      > JMPZ                                                         ~13, ->23
   20    10    >   FRAMELESS_ICALL_2                strpos              ~14     !1, '%5D%3A'
         11        ASSIGN                                                       !5, ~14
   21    12      > JMPZ                                                         !5, ->21
   23    13    >   ADD                                                  ~16     !5, 2
         14        FRAMELESS_ICALL_2                substr              ~17     !1, ~16
         15        ASSIGN                                                       !4, ~17
   24    16        ADD                                                  ~19     !5, 1
         17        FRAMELESS_ICALL_3                substr              ~20     !1, 0
         18        OP_DATA                                                      ~19
         19        ASSIGN                                                       !3, ~20
   21    20      > JMP                                                          ->22
   26    21    >   ASSIGN                                                       !3, !1
   19    22    > > JMP                                                          ->32
   29    23    >   INIT_FCALL                                                   'explode'
         24        SEND_VAL                                                     '%3A'
         25        SEND_VAR                                                     !1
         26        DO_ICALL                                             $23     
         27        FETCH_LIST_R                                         $24     $23, 0
         28        ASSIGN                                                       !3, $24
         29        FETCH_LIST_R                                         $26     $23, 1
         30        ASSIGN                                                       !4, $26
         31        FREE                                                         $23
   17    32    > > JMP                                                          ->34
   33    33    >   ASSIGN                                                       !3, !1
   36    34    >   CONCAT                                               ~29     !2, '%3A+Hostname%3A+'
         35        CONCAT                                               ~30     ~29, !3
         36        CONCAT                                               ~31     ~30, '+Port%3A+'
         37        CONCAT                                               ~32     ~31, !4
         38        CONCAT                                               ~33     ~32, '%0A'
         39        ECHO                                                         ~33
   12    40      > JMP                                                          ->2
         41    >   FE_FREE                                                      $7
   38    42      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
172.99 ms | 1655 KiB | 14 Q