3v4l.org

run code in 300+ PHP versions simultaneously
<?php define( COL_MIN_AVG, 64 ); define( COL_MAX_AVG, 192 ); define( COL_STEP, 16 ); // (192 - 64) / 16 = 8 // 8 ^ 3 = 512 colors function usercolor( $username ) { $range = COL_MAX_AVG - COL_MIN_AVG; $factor = $range / 256; $offset = COL_MIN_AVG; $base_hash = substr(md5($username), 0, 6); $b_R = hexdec(substr($base_hash,0,2)); $b_G = hexdec(substr($base_hash,2,2)); $b_B = hexdec(substr($base_hash,4,2)); $f_R = floor((floor($b_R * $factor) + $offset) / COL_STEP) * COL_STEP; $f_G = floor((floor($b_G * $factor) + $offset) / COL_STEP) * COL_STEP; $f_B = floor((floor($b_B * $factor) + $offset) / COL_STEP) * COL_STEP; return printf('#%02x%02x%02x', $f_R, $f_G, $f_B); } for( $i=0; $i<30; $i++ ) { printf('<div style="height: 100px; width: 100px; background-color: %s">&nbsp;</div>'."\n", usercolor(rand())); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 17
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 17
Branch analysis from position: 29
Branch analysis from position: 17
filename:       /in/rIvBX
function name:  (null)
number of ops:  30
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'define'
          1        FETCH_CONSTANT                                   ~1      'COL_MIN_AVG'
          2        SEND_VAL                                                 ~1
          3        SEND_VAL                                                 64
          4        DO_ICALL                                                 
    3     5        INIT_FCALL                                               'define'
          6        FETCH_CONSTANT                                   ~3      'COL_MAX_AVG'
          7        SEND_VAL                                                 ~3
          8        SEND_VAL                                                 192
          9        DO_ICALL                                                 
    4    10        INIT_FCALL                                               'define'
         11        FETCH_CONSTANT                                   ~5      'COL_STEP'
         12        SEND_VAL                                                 ~5
         13        SEND_VAL                                                 16
         14        DO_ICALL                                                 
   26    15        ASSIGN                                                   !0, 0
         16      > JMP                                                      ->27
   27    17    >   INIT_FCALL                                               'printf'
         18        SEND_VAL                                                 '%3Cdiv+style%3D%22height%3A+100px%3B+width%3A+100px%3B+background-color%3A+%25s%22%3E%26nbsp%3B%3C%2Fdiv%3E%0A'
         19        INIT_FCALL                                               'usercolor'
         20        INIT_FCALL                                               'rand'
         21        DO_ICALL                                         $8      
         22        SEND_VAR                                                 $8
         23        DO_FCALL                                      0  $9      
         24        SEND_VAR                                                 $9
         25        DO_ICALL                                                 
   26    26        PRE_INC                                                  !0
         27    >   IS_SMALLER                                               !0, 30
         28      > JMPNZ                                                    ~12, ->17
   28    29    > > RETURN                                                   1

Function usercolor:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rIvBX
function name:  usercolor
number of ops:  92
compiled vars:  !0 = $username, !1 = $range, !2 = $factor, !3 = $offset, !4 = $base_hash, !5 = $b_R, !6 = $b_G, !7 = $b_B, !8 = $f_R, !9 = $f_G, !10 = $f_B
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        FETCH_CONSTANT                                   ~11     'COL_MAX_AVG'
          2        FETCH_CONSTANT                                   ~12     'COL_MIN_AVG'
          3        SUB                                              ~13     ~11, ~12
          4        ASSIGN                                                   !1, ~13
   11     5        DIV                                              ~15     !1, 256
          6        ASSIGN                                                   !2, ~15
   12     7        FETCH_CONSTANT                                   ~17     'COL_MIN_AVG'
          8        ASSIGN                                                   !3, ~17
   14     9        INIT_FCALL                                               'substr'
         10        INIT_FCALL                                               'md5'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $19     
         13        SEND_VAR                                                 $19
         14        SEND_VAL                                                 0
         15        SEND_VAL                                                 6
         16        DO_ICALL                                         $20     
         17        ASSIGN                                                   !4, $20
   15    18        INIT_FCALL                                               'hexdec'
         19        INIT_FCALL                                               'substr'
         20        SEND_VAR                                                 !4
         21        SEND_VAL                                                 0
         22        SEND_VAL                                                 2
         23        DO_ICALL                                         $22     
         24        SEND_VAR                                                 $22
         25        DO_ICALL                                         $23     
         26        ASSIGN                                                   !5, $23
   16    27        INIT_FCALL                                               'hexdec'
         28        INIT_FCALL                                               'substr'
         29        SEND_VAR                                                 !4
         30        SEND_VAL                                                 2
         31        SEND_VAL                                                 2
         32        DO_ICALL                                         $25     
         33        SEND_VAR                                                 $25
         34        DO_ICALL                                         $26     
         35        ASSIGN                                                   !6, $26
   17    36        INIT_FCALL                                               'hexdec'
         37        INIT_FCALL                                               'substr'
         38        SEND_VAR                                                 !4
         39        SEND_VAL                                                 4
         40        SEND_VAL                                                 2
         41        DO_ICALL                                         $28     
         42        SEND_VAR                                                 $28
         43        DO_ICALL                                         $29     
         44        ASSIGN                                                   !7, $29
   19    45        INIT_FCALL                                               'floor'
         46        INIT_FCALL                                               'floor'
         47        MUL                                              ~31     !5, !2
         48        SEND_VAL                                                 ~31
         49        DO_ICALL                                         $32     
         50        ADD                                              ~33     $32, !3
         51        FETCH_CONSTANT                                   ~34     'COL_STEP'
         52        DIV                                              ~35     ~33, ~34
         53        SEND_VAL                                                 ~35
         54        DO_ICALL                                         $36     
         55        FETCH_CONSTANT                                   ~37     'COL_STEP'
         56        MUL                                              ~38     $36, ~37
         57        ASSIGN                                                   !8, ~38
   20    58        INIT_FCALL                                               'floor'
         59        INIT_FCALL                                               'floor'
         60        MUL                                              ~40     !6, !2
         61        SEND_VAL                                                 ~40
         62        DO_ICALL                                         $41     
         63        ADD                                              ~42     $41, !3
         64        FETCH_CONSTANT                                   ~43     'COL_STEP'
         65        DIV                                              ~44     ~42, ~43
         66        SEND_VAL                                                 ~44
         67        DO_ICALL                                         $45     
         68        FETCH_CONSTANT                                   ~46     'COL_STEP'
         69        MUL                                              ~47     $45, ~46
         70        ASSIGN                                                   !9, ~47
   21    71        INIT_FCALL                                               'floor'
         72        INIT_FCALL                                               'floor'
         73        MUL                                              ~49     !7, !2
         74        SEND_VAL                                                 ~49
         75        DO_ICALL                                         $50     
         76        ADD                                              ~51     $50, !3
         77        FETCH_CONSTANT                                   ~52     'COL_STEP'
         78        DIV                                              ~53     ~51, ~52
         79        SEND_VAL                                                 ~53
         80        DO_ICALL                                         $54     
         81        FETCH_CONSTANT                                   ~55     'COL_STEP'
         82        MUL                                              ~56     $54, ~55
         83        ASSIGN                                                   !10, ~56
   23    84        INIT_FCALL                                               'printf'
         85        SEND_VAL                                                 '%23%2502x%2502x%2502x'
         86        SEND_VAR                                                 !8
         87        SEND_VAR                                                 !9
         88        SEND_VAR                                                 !10
         89        DO_ICALL                                         $58     
         90      > RETURN                                                   $58
   24    91*     > RETURN                                                   null

End of function usercolor

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.41 ms | 1407 KiB | 28 Q