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); if(!is_array($temp)){ 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('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/Q5kCF
function name:  (null)
number of ops:  17
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   INIT_FCALL                                               'swift_rgb2hex'
          1        SEND_VAL                                                 'rgba%280%2C0%2C0%29'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
   26     4        INIT_FCALL                                               'swift_rgb2hex'
          5        SEND_VAL                                                 'boom'
          6        DO_FCALL                                      0  $1      
          7        ECHO                                                     $1
   28     8        INIT_FCALL                                               'swift_rgb2hex'
          9        SEND_VAL                                                 'FFFFFF'
         10        DO_FCALL                                      0  $2      
         11        ECHO                                                     $2
   29    12        INIT_FCALL                                               'swift_rgb2hex'
         13        SEND_VAL                                                 'rgba%280%2C0%2C0%29'
         14        DO_FCALL                                      0  $3      
         15        ECHO                                                     $3
         16      > 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 = 43) Position 1 = 15, Position 2 = 16
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/Q5kCF
function name:  swift_rgb2hex
number of ops:  65
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        TYPE_CHECK                                  128  ~8      !3
         13        BOOL_NOT                                         ~9      ~8
         14      > JMPZ                                                     ~9, ->16
   12    15    > > RETURN                                                   !0
   14    16    >   FETCH_DIM_R                                      ~10     !3, 1
         17        ASSIGN                                                   !0, ~10
   15    18        INIT_FCALL                                               'explode'
         19        SEND_VAL                                                 '%29'
         20        SEND_VAR                                                 !0
         21        DO_ICALL                                         $12     
         22        ASSIGN                                                   !3, $12
   16    23        FETCH_DIM_R                                      ~14     !3, 0
         24        ASSIGN                                                   !0, ~14
   17    25        INIT_FCALL                                               'explode'
         26        SEND_VAL                                                 '%2C'
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                         $16     
         29        ASSIGN                                                   !0, $16
   19    30        INIT_FCALL                                               'str_pad'
         31        INIT_FCALL                                               'dechex'
         32        FETCH_DIM_R                                      ~18     !0, 0
         33        SEND_VAL                                                 ~18
         34        DO_ICALL                                         $19     
         35        SEND_VAR                                                 $19
         36        SEND_VAL                                                 2
         37        SEND_VAL                                                 '0'
         38        SEND_VAL                                                 0
         39        DO_ICALL                                         $20     
         40        ASSIGN_OP                                     8          !2, $20
   20    41        INIT_FCALL                                               'str_pad'
         42        INIT_FCALL                                               'dechex'
         43        FETCH_DIM_R                                      ~22     !0, 1
         44        SEND_VAL                                                 ~22
         45        DO_ICALL                                         $23     
         46        SEND_VAR                                                 $23
         47        SEND_VAL                                                 2
         48        SEND_VAL                                                 '0'
         49        SEND_VAL                                                 0
         50        DO_ICALL                                         $24     
         51        ASSIGN_OP                                     8          !2, $24
   21    52        INIT_FCALL                                               'str_pad'
         53        INIT_FCALL                                               'dechex'
         54        FETCH_DIM_R                                      ~26     !0, 2
         55        SEND_VAL                                                 ~26
         56        DO_ICALL                                         $27     
         57        SEND_VAR                                                 $27
         58        SEND_VAL                                                 2
         59        SEND_VAL                                                 '0'
         60        SEND_VAL                                                 0
         61        DO_ICALL                                         $28     
         62        ASSIGN_OP                                     8          !2, $28
   22    63      > RETURN                                                   !2
   23    64*     > RETURN                                                   null

End of function swift_rgb2hex

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.4 ms | 1402 KiB | 23 Q