3v4l.org

run code in 300+ PHP versions simultaneously
<?php print_r(hex2rgb("#AADDFF")); function hex2rgb($hex) { //if (substr($hex,0,1)=="#"): // $hex=substr($hex, 1); //endif; $hex = str_replace("#","",$hex); if (strlen($hex)==3): $hex=$hex[0].$hex[0].$hex[1].$hex[1].$hex[2].$hex[2]; elseif (strlen($hex)!=6): return false; else: $rgb=array(); $rgb[0] = hexdec(substr($hex,0,2)); // red $rgb[1] = hexdec(substr($hex,2,2)); // green $rgb[2] = hexdec(substr($hex,4,2)); // blue return $rgb; endif; } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gsARn
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'print_r'
          1        INIT_FCALL_BY_NAME                                       'hex2rgb'
          2        SEND_VAL_EX                                              '%23AADDFF'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
   25     6      > RETURN                                                   1

Function hex2rgb:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 23
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 60
Branch analysis from position: 60
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 28
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gsARn
function name:  hex2rgb
number of ops:  61
compiled vars:  !0 = $hex, !1 = $rgb
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
   10     1        INIT_FCALL                                               'str_replace'
          2        SEND_VAL                                                 '%23'
          3        SEND_VAL                                                 ''
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
          6        ASSIGN                                                   !0, $2
   12     7        STRLEN                                           ~4      !0
          8        IS_EQUAL                                                 ~4, 3
          9      > JMPZ                                                     ~5, ->23
   13    10    >   FETCH_DIM_R                                      ~6      !0, 0
         11        FETCH_DIM_R                                      ~7      !0, 0
         12        CONCAT                                           ~8      ~6, ~7
         13        FETCH_DIM_R                                      ~9      !0, 1
         14        CONCAT                                           ~10     ~8, ~9
         15        FETCH_DIM_R                                      ~11     !0, 1
         16        CONCAT                                           ~12     ~10, ~11
         17        FETCH_DIM_R                                      ~13     !0, 2
         18        CONCAT                                           ~14     ~12, ~13
         19        FETCH_DIM_R                                      ~15     !0, 2
         20        CONCAT                                           ~16     ~14, ~15
         21        ASSIGN                                                   !0, ~16
         22      > JMP                                                      ->60
   14    23    >   STRLEN                                           ~18     !0
         24        IS_NOT_EQUAL                                             ~18, 6
         25      > JMPZ                                                     ~19, ->28
   15    26    > > RETURN                                                   <false>
         27*       JMP                                                      ->60
   17    28    >   ASSIGN                                                   !1, <array>
   18    29        INIT_FCALL                                               'hexdec'
         30        INIT_FCALL                                               'substr'
         31        SEND_VAR                                                 !0
         32        SEND_VAL                                                 0
         33        SEND_VAL                                                 2
         34        DO_ICALL                                         $22     
         35        SEND_VAR                                                 $22
         36        DO_ICALL                                         $23     
         37        ASSIGN_DIM                                               !1, 0
         38        OP_DATA                                                  $23
   19    39        INIT_FCALL                                               'hexdec'
         40        INIT_FCALL                                               'substr'
         41        SEND_VAR                                                 !0
         42        SEND_VAL                                                 2
         43        SEND_VAL                                                 2
         44        DO_ICALL                                         $25     
         45        SEND_VAR                                                 $25
         46        DO_ICALL                                         $26     
         47        ASSIGN_DIM                                               !1, 1
         48        OP_DATA                                                  $26
   20    49        INIT_FCALL                                               'hexdec'
         50        INIT_FCALL                                               'substr'
         51        SEND_VAR                                                 !0
         52        SEND_VAL                                                 4
         53        SEND_VAL                                                 2
         54        DO_ICALL                                         $28     
         55        SEND_VAR                                                 $28
         56        DO_ICALL                                         $29     
         57        ASSIGN_DIM                                               !1, 2
         58        OP_DATA                                                  $29
   21    59      > RETURN                                                   !1
   23    60    > > RETURN                                                   null

End of function hex2rgb

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.12 ms | 1404 KiB | 21 Q