3v4l.org

run code in 300+ PHP versions simultaneously
<?php function setPermission( $permissions, $type, $value) { if ($value) return $permissions | $type; else return $permissions & ~$type; } echo setPermission(2|4|16, 4|8, false) . "\n"; // 2|16 = 18 echo setPermission(2|4|16, 4|8, true ) . "\n"; // 2|4|8|16 = 30 echo setPermission(1|2|4, 4|8|16, false) . "\n"; // 1|2 = 3
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pvgBW
function name:  (null)
number of ops:  22
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                               'setpermission'
          1        SEND_VAL                                                 22
          2        SEND_VAL                                                 12
          3        SEND_VAL                                                 <false>
          4        DO_FCALL                                      0  $0      
          5        CONCAT                                           ~1      $0, '%0A'
          6        ECHO                                                     ~1
   11     7        INIT_FCALL                                               'setpermission'
          8        SEND_VAL                                                 22
          9        SEND_VAL                                                 12
         10        SEND_VAL                                                 <true>
         11        DO_FCALL                                      0  $2      
         12        CONCAT                                           ~3      $2, '%0A'
         13        ECHO                                                     ~3
   12    14        INIT_FCALL                                               'setpermission'
         15        SEND_VAL                                                 7
         16        SEND_VAL                                                 28
         17        SEND_VAL                                                 <false>
         18        DO_FCALL                                      0  $4      
         19        CONCAT                                           ~5      $4, '%0A'
         20        ECHO                                                     ~5
         21      > RETURN                                                   1

Function setpermission:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pvgBW
function name:  setPermission
number of ops:  11
compiled vars:  !0 = $permissions, !1 = $type, !2 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    4     3      > JMPZ                                                     !2, ->7
    5     4    >   BW_OR                                            ~3      !0, !1
          5      > RETURN                                                   ~3
          6*       JMP                                                      ->10
    7     7    >   BW_NOT                                           ~4      !1
          8        BW_AND                                           ~5      !0, ~4
          9      > RETURN                                                   ~5
    8    10*     > RETURN                                                   null

End of function setpermission

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
129.58 ms | 1403 KiB | 16 Q