3v4l.org

run code in 300+ PHP versions simultaneously
<?php function swift_rgb2hex($rgb,$hash=true) { if($rgb == NULL){ return 'none'; } if($hash) $hex = '#'; $temp = explode('(',$rgb); print_r( $temp); if(!is_array($temp) || count($temp)<=1){ return $rgb; } $rgb = $temp[1]; $temp = explode(')',$rgb); $rgb = $temp[0]; $rgb = explode(',',$rgb); $hex .= str_pad(dechex($rgb[0]), 2, "0", STR_PAD_LEFT); $hex .= str_pad(dechex($rgb[1]), 2, "0", STR_PAD_LEFT); $hex .= str_pad(dechex($rgb[2]), 2, "0", STR_PAD_LEFT); return $hex; } /* echo swift_rgb2hex('rgba(0,0,0)'); echo swift_rgb2hex('rgba(255,255,0)'); echo swift_rgb2hex('boom'); echo swift_rgb2hex('FFFFFF'); */ echo swift_rgb2hex('rgba(0,0,0)');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ngirK
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   INIT_FCALL                                               'swift_rgb2hex'
          1        SEND_VAL                                                 'rgba%280%2C0%2C0%29'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function swift_rgb2hex:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
2 jumps found. (Code = 47) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 23
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
Branch analysis from position: 7
filename:       /in/ngirK
function name:  swift_rgb2hex
number of ops:  72
compiled vars:  !0 = $rgb, !1 = $hash, !2 = $hex, !3 = $temp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <true>
    4     2        IS_EQUAL                                                 !0, null
          3      > JMPZ                                                     ~4, ->5
    5     4    > > RETURN                                                   'none'
    7     5    > > JMPZ                                                     !1, ->7
    8     6    >   ASSIGN                                                   !2, '%23'
   10     7    >   INIT_FCALL                                               'explode'
          8        SEND_VAL                                                 '%28'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $6      
         11        ASSIGN                                                   !3, $6
   11    12        INIT_FCALL                                               'print_r'
         13        SEND_VAR                                                 !3
         14        DO_ICALL                                                 
   12    15        TYPE_CHECK                                  128  ~9      !3
         16        BOOL_NOT                                         ~10     ~9
         17      > JMPNZ_EX                                         ~10     ~10, ->21
         18    >   COUNT                                            ~11     !3
         19        IS_SMALLER_OR_EQUAL                              ~12     ~11, 1
         20        BOOL                                             ~10     ~12
         21    > > JMPZ                                                     ~10, ->23
   13    22    > > RETURN                                                   !0
   15    23    >   FETCH_DIM_R                                      ~13     !3, 1
         24        ASSIGN                                                   !0, ~13
   16    25        INIT_FCALL                                               'explode'
         26        SEND_VAL                                                 '%29'
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                         $15     
         29        ASSIGN                                                   !3, $15
   17    30        FETCH_DIM_R                                      ~17     !3, 0
         31        ASSIGN                                                   !0, ~17
   18    32        INIT_FCALL                                               'explode'
         33        SEND_VAL                                                 '%2C'
         34        SEND_VAR                                                 !0
         35        DO_ICALL                                         $19     
         36        ASSIGN                                                   !0, $19
   20    37        INIT_FCALL                                               'str_pad'
         38        INIT_FCALL                                               'dechex'
         39        FETCH_DIM_R                                      ~21     !0, 0
         40        SEND_VAL                                                 ~21
         41        DO_ICALL                                         $22     
         42        SEND_VAR                                                 $22
         43        SEND_VAL                                                 2
         44        SEND_VAL                                                 '0'
         45        SEND_VAL                                                 0
         46        DO_ICALL                                         $23     
         47        ASSIGN_OP                                     8          !2, $23
   21    48        INIT_FCALL                                               'str_pad'
         49        INIT_FCALL                                               'dechex'
         50        FETCH_DIM_R                                      ~25     !0, 1
         51        SEND_VAL                                                 ~25
         52        DO_ICALL                                         $26     
         53        SEND_VAR                                                 $26
         54        SEND_VAL                                                 2
         55        SEND_VAL                                                 '0'
         56        SEND_VAL                                                 0
         57        DO_ICALL                                         $27     
         58        ASSIGN_OP                                     8          !2, $27
   22    59        INIT_FCALL                                               'str_pad'
         60        INIT_FCALL                                               'dechex'
         61        FETCH_DIM_R                                      ~29     !0, 2
         62        SEND_VAL                                                 ~29
         63        DO_ICALL                                         $30     
         64        SEND_VAR                                                 $30
         65        SEND_VAL                                                 2
         66        SEND_VAL                                                 '0'
         67        SEND_VAL                                                 0
         68        DO_ICALL                                         $31     
         69        ASSIGN_OP                                     8          !2, $31
   23    70      > RETURN                                                   !2
   24    71*     > RETURN                                                   null

End of function swift_rgb2hex

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.9 ms | 1403 KiB | 22 Q