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

End of function swift_rgb2hex

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.14 ms | 1394 KiB | 25 Q