3v4l.org

run code in 300+ PHP versions simultaneously
<? /** * Given a Hex IP Address, this script will convert * and display Decimal and Binary representations of * the IP Address. * * This script was created for a one time personal use. * It works for well for valid hex addresses, but may return * unexpected results for invalid hex input (non hex characters, * too many/few hex digits, etc). * * @author Josh Grochowski (josh@kastang.com) * */ //determines if the input is through a command line, or web browser if(isset($argv[1])) { $HEX_IP = $argv[1]; } else if(isset($_GET["hexip"])) { $HEX_IP = $_GET["hexip"]; } else { throw new Exception("No HEX Input through CLI or GET."); } $HEX_IP = str_split($HEX_IP, 2); $BIN_IP = ''; foreach($HEX_IP as $h) { $d = base_convert($h, 16, 2); //Pads the Binary string with 0's if length is less then 8. if(strlen($d) < 8) { $len = strlen($d); while($len < 8) { $d = '0'.$d; $len++; } } $BIN_IP .= $d; } //Displays the length of the Binary string and shows the IP in Binary Notation echo 'Binary Length: '. strlen($BIN_IP)."\n"; echo $BIN_IP."\n\n"; //Splits the string into 4, 8 bit segments. $BIN_IP = str_split($BIN_IP, 8); //Converts each Binary block to a decimal and forms the IP address. echo 'Decimal IP: '; $ip = ''; foreach($BIN_IP as $x) { $ip .= base_convert($x, 2, 10).'.'; } //Displays the IP Address in Decimal format. echo substr($ip, 0, -1)."\n"; ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 5
Branch analysis from position: 2
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 43
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 43
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 41
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 36
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 36
Branch analysis from position: 41
Branch analysis from position: 36
Branch analysis from position: 41
Branch analysis from position: 43
2 jumps found. (Code = 77) Position 1 = 58, Position 2 = 67
Branch analysis from position: 58
2 jumps found. (Code = 78) Position 1 = 59, Position 2 = 67
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
Branch analysis from position: 67
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 67
Branch analysis from position: 43
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 12
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/hX9IH
function name:  (null)
number of ops:  76
compiled vars:  !0 = $argv, !1 = $HEX_IP, !2 = $BIN_IP, !3 = $h, !4 = $d, !5 = $len, !6 = $ip, !7 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ISSET_ISEMPTY_DIM_OBJ                         0          !0, 1
          1      > JMPZ                                                     ~8, ->5
   18     2    >   FETCH_DIM_R                                      ~9      !0, 1
          3        ASSIGN                                                   !1, ~9
          4      > JMP                                                      ->16
   19     5    >   FETCH_IS                                         ~11     '_GET'
          6        ISSET_ISEMPTY_DIM_OBJ                         0          ~11, 'hexip'
          7      > JMPZ                                                     ~12, ->12
   20     8    >   FETCH_R                      global              ~13     '_GET'
          9        FETCH_DIM_R                                      ~14     ~13, 'hexip'
         10        ASSIGN                                                   !1, ~14
         11      > JMP                                                      ->16
   22    12    >   NEW                                              $16     'Exception'
         13        SEND_VAL_EX                                              'No+HEX+Input+through+CLI+or+GET.'
         14        DO_FCALL                                      0          
         15      > THROW                                         0          $16
   25    16    >   INIT_FCALL                                               'str_split'
         17        SEND_VAR                                                 !1
         18        SEND_VAL                                                 2
         19        DO_ICALL                                         $18     
         20        ASSIGN                                                   !1, $18
   27    21        ASSIGN                                                   !2, ''
   28    22      > FE_RESET_R                                       $21     !1, ->43
         23    > > FE_FETCH_R                                               $21, !3, ->43
   29    24    >   INIT_FCALL                                               'base_convert'
         25        SEND_VAR                                                 !3
         26        SEND_VAL                                                 16
         27        SEND_VAL                                                 2
         28        DO_ICALL                                         $22     
         29        ASSIGN                                                   !4, $22
   32    30        STRLEN                                           ~24     !4
         31        IS_SMALLER                                               ~24, 8
         32      > JMPZ                                                     ~25, ->41
   33    33    >   STRLEN                                           ~26     !4
         34        ASSIGN                                                   !5, ~26
   34    35      > JMP                                                      ->39
   35    36    >   CONCAT                                           ~28     '0', !4
         37        ASSIGN                                                   !4, ~28
   36    38        PRE_INC                                                  !5
   34    39    >   IS_SMALLER                                               !5, 8
         40      > JMPNZ                                                    ~31, ->36
   39    41    >   ASSIGN_OP                                     8          !2, !4
   28    42      > JMP                                                      ->23
         43    >   FE_FREE                                                  $21
   43    44        STRLEN                                           ~33     !2
         45        CONCAT                                           ~34     'Binary+Length%3A+', ~33
         46        CONCAT                                           ~35     ~34, '%0A'
         47        ECHO                                                     ~35
   44    48        CONCAT                                           ~36     !2, '%0A%0A'
         49        ECHO                                                     ~36
   47    50        INIT_FCALL                                               'str_split'
         51        SEND_VAR                                                 !2
         52        SEND_VAL                                                 8
         53        DO_ICALL                                         $37     
         54        ASSIGN                                                   !2, $37
   50    55        ECHO                                                     'Decimal+IP%3A+'
   51    56        ASSIGN                                                   !6, ''
   52    57      > FE_RESET_R                                       $40     !2, ->67
         58    > > FE_FETCH_R                                               $40, !7, ->67
   53    59    >   INIT_FCALL                                               'base_convert'
         60        SEND_VAR                                                 !7
         61        SEND_VAL                                                 2
         62        SEND_VAL                                                 10
         63        DO_ICALL                                         $41     
         64        CONCAT                                           ~42     $41, '.'
         65        ASSIGN_OP                                     8          !6, ~42
   52    66      > JMP                                                      ->58
         67    >   FE_FREE                                                  $40
   57    68        INIT_FCALL                                               'substr'
         69        SEND_VAR                                                 !6
         70        SEND_VAL                                                 0
         71        SEND_VAL                                                 -1
         72        DO_ICALL                                         $44     
         73        CONCAT                                           ~45     $44, '%0A'
         74        ECHO                                                     ~45
   59    75      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.04 ms | 1408 KiB | 19 Q