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

End of function swift_rgb2hex

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.93 ms | 1403 KiB | 20 Q