3v4l.org

run code in 300+ PHP versions simultaneously
<?php function highestBitsOfByte(int $byte, int $count = 2):int { if($count < 0 OR $count > 8) return false; //Error return ($byte&0xFF) >> (8-$count); } $input = 0b10011110; $r = highestBitsOfByte($input,2); echo sprintf('%08b',$r);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1lAvO
function name:  (null)
number of ops:  12
compiled vars:  !0 = $input, !1 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ASSIGN                                                   !0, 158
   10     1        INIT_FCALL                                               'highestbitsofbyte'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 2
          4        DO_FCALL                                      0  $3      
          5        ASSIGN                                                   !1, $3
   12     6        INIT_FCALL                                               'sprintf'
          7        SEND_VAL                                                 '%2508b'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $5      
         10        ECHO                                                     $5
         11      > RETURN                                                   1

Function highestbitsofbyte:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/1lAvO
function name:  highestBitsOfByte
number of ops:  16
compiled vars:  !0 = $byte, !1 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      2
    4     2        IS_SMALLER                                       ~2      !1, 0
          3      > JMPNZ_EX                                         ~2      ~2, ->6
          4    >   IS_SMALLER                                       ~3      8, !1
          5        BOOL                                             ~2      ~3
          6    > > JMPZ                                                     ~2, ->9
          7    >   VERIFY_RETURN_TYPE                               ~4      <false>
          8      > RETURN                                                   ~4
    5     9    >   BW_AND                                           ~5      !0, 255
         10        SUB                                              ~6      8, !1
         11        SR                                               ~7      ~5, ~6
         12        VERIFY_RETURN_TYPE                                       ~7
         13      > RETURN                                                   ~7
    6    14*       VERIFY_RETURN_TYPE                                       
         15*     > RETURN                                                   null

End of function highestbitsofbyte

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.59 ms | 1008 KiB | 15 Q