3v4l.org

run code in 300+ PHP versions simultaneously
<?php function swift_rgb2hex($rgb,$hash=true) { if($rgb == NULL){ return 'none'; } if($hash) $hex = '#'; if(strpos($rgb,'rgb') === false){ return '#'.$rgb; } $temp = explode('(',$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(22,22,22,1)'); echo swift_rgb2hex('FFFFFF'); echo swift_rgb2hex('bamam'); echo swift_rgb2hex('rgba(255,255,0,1)');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C5cBs
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%2822%2C22%2C22%2C1%29'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
   24     4        INIT_FCALL                                               'swift_rgb2hex'
          5        SEND_VAL                                                 'FFFFFF'
          6        DO_FCALL                                      0  $1      
          7        ECHO                                                     $1
   25     8        INIT_FCALL                                               'swift_rgb2hex'
          9        SEND_VAL                                                 'bamam'
         10        DO_FCALL                                      0  $2      
         11        ECHO                                                     $2
   26    12        INIT_FCALL                                               'swift_rgb2hex'
         13        SEND_VAL                                                 'rgba%28255%2C255%2C0%2C1%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 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/C5cBs
function name:  swift_rgb2hex
number of ops:  69
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                                               'strpos'
          8        SEND_VAR                                                 !0
          9        SEND_VAL                                                 'rgb'
         10        DO_ICALL                                         $6      
         11        TYPE_CHECK                                    4          $6
         12      > JMPZ                                                     ~7, ->15
   10    13    >   CONCAT                                           ~8      '%23', !0
         14      > RETURN                                                   ~8
   12    15    >   INIT_FCALL                                               'explode'
         16        SEND_VAL                                                 '%28'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $9      
         19        ASSIGN                                                   !3, $9
   13    20        FETCH_DIM_R                                      ~11     !3, 1
         21        ASSIGN                                                   !0, ~11
   14    22        INIT_FCALL                                               'explode'
         23        SEND_VAL                                                 '%29'
         24        SEND_VAR                                                 !0
         25        DO_ICALL                                         $13     
         26        ASSIGN                                                   !3, $13
   15    27        FETCH_DIM_R                                      ~15     !3, 0
         28        ASSIGN                                                   !0, ~15
   16    29        INIT_FCALL                                               'explode'
         30        SEND_VAL                                                 '%2C'
         31        SEND_VAR                                                 !0
         32        DO_ICALL                                         $17     
         33        ASSIGN                                                   !0, $17
   18    34        INIT_FCALL                                               'str_pad'
         35        INIT_FCALL                                               'dechex'
         36        FETCH_DIM_R                                      ~19     !0, 0
         37        SEND_VAL                                                 ~19
         38        DO_ICALL                                         $20     
         39        SEND_VAR                                                 $20
         40        SEND_VAL                                                 2
         41        SEND_VAL                                                 '0'
         42        SEND_VAL                                                 0
         43        DO_ICALL                                         $21     
         44        ASSIGN_OP                                     8          !2, $21
   19    45        INIT_FCALL                                               'str_pad'
         46        INIT_FCALL                                               'dechex'
         47        FETCH_DIM_R                                      ~23     !0, 1
         48        SEND_VAL                                                 ~23
         49        DO_ICALL                                         $24     
         50        SEND_VAR                                                 $24
         51        SEND_VAL                                                 2
         52        SEND_VAL                                                 '0'
         53        SEND_VAL                                                 0
         54        DO_ICALL                                         $25     
         55        ASSIGN_OP                                     8          !2, $25
   20    56        INIT_FCALL                                               'str_pad'
         57        INIT_FCALL                                               'dechex'
         58        FETCH_DIM_R                                      ~27     !0, 2
         59        SEND_VAL                                                 ~27
         60        DO_ICALL                                         $28     
         61        SEND_VAR                                                 $28
         62        SEND_VAL                                                 2
         63        SEND_VAL                                                 '0'
         64        SEND_VAL                                                 0
         65        DO_ICALL                                         $29     
         66        ASSIGN_OP                                     8          !2, $29
   21    67      > RETURN                                                   !2
   22    68*     > RETURN                                                   null

End of function swift_rgb2hex

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.16 ms | 1407 KiB | 25 Q