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) || 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('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/qpmqq
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 = 47) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 20
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
Branch analysis from position: 7
filename:       /in/qpmqq
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
-------------------------------------------------------------------------------------
    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      > JMPNZ_EX                                         ~9      ~9, ->18
         15    >   COUNT                                            ~10     !3
         16        IS_SMALLER_OR_EQUAL                              ~11     ~10, 1
         17        BOOL                                             ~9      ~11
         18    > > JMPZ                                                     ~9, ->20
   12    19    > > RETURN                                                   !0
   14    20    >   FETCH_DIM_R                                      ~12     !3, 1
         21        ASSIGN                                                   !0, ~12
   15    22        INIT_FCALL                                               'explode'
         23        SEND_VAL                                                 '%29'
         24        SEND_VAR                                                 !0
         25        DO_ICALL                                         $14     
         26        ASSIGN                                                   !3, $14
   16    27        FETCH_DIM_R                                      ~16     !3, 0
         28        ASSIGN                                                   !0, ~16
   17    29        INIT_FCALL                                               'explode'
         30        SEND_VAL                                                 '%2C'
         31        SEND_VAR                                                 !0
         32        DO_ICALL                                         $18     
         33        ASSIGN                                                   !0, $18
   19    34        INIT_FCALL                                               'str_pad'
         35        INIT_FCALL                                               'dechex'
         36        FETCH_DIM_R                                      ~20     !0, 0
         37        SEND_VAL                                                 ~20
         38        DO_ICALL                                         $21     
         39        SEND_VAR                                                 $21
         40        SEND_VAL                                                 2
         41        SEND_VAL                                                 '0'
         42        SEND_VAL                                                 0
         43        DO_ICALL                                         $22     
         44        ASSIGN_OP                                     8          !2, $22
   20    45        INIT_FCALL                                               'str_pad'
         46        INIT_FCALL                                               'dechex'
         47        FETCH_DIM_R                                      ~24     !0, 1
         48        SEND_VAL                                                 ~24
         49        DO_ICALL                                         $25     
         50        SEND_VAR                                                 $25
         51        SEND_VAL                                                 2
         52        SEND_VAL                                                 '0'
         53        SEND_VAL                                                 0
         54        DO_ICALL                                         $26     
         55        ASSIGN_OP                                     8          !2, $26
   21    56        INIT_FCALL                                               'str_pad'
         57        INIT_FCALL                                               'dechex'
         58        FETCH_DIM_R                                      ~28     !0, 2
         59        SEND_VAL                                                 ~28
         60        DO_ICALL                                         $29     
         61        SEND_VAR                                                 $29
         62        SEND_VAL                                                 2
         63        SEND_VAL                                                 '0'
         64        SEND_VAL                                                 0
         65        DO_ICALL                                         $30     
         66        ASSIGN_OP                                     8          !2, $30
   22    67      > RETURN                                                   !2
   23    68*     > RETURN                                                   null

End of function swift_rgb2hex

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.57 ms | 1407 KiB | 23 Q