3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @param int $date Unix time * @return bool */ function isActive($date) { $days = [1 => 0b1000000, 0b0100000, 0b0010000, 0b0001000, 0b0000100, 0b0000010, 0b0000001, ]; $week = 0b1001110; $day = $days[date('N', $date)]; return ($week & $day) === $day; } function test($date) { printf("%s is %s\n", date('r', $date), isActive($date) ? 'TRUE' : 'FALSE'); } test(strtotime('monday')); test(strtotime('tuesday')); test(strtotime('wednesday')); test(strtotime('thursday')); test(strtotime('friday')); test(strtotime('saturday')); test(strtotime('sunday'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tUV3B
function name:  (null)
number of ops:  43
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   INIT_FCALL                                               'test'
          1        INIT_FCALL                                               'strtotime'
          2        SEND_VAL                                                 'monday'
          3        DO_ICALL                                         $0      
          4        SEND_VAR                                                 $0
          5        DO_FCALL                                      0          
   29     6        INIT_FCALL                                               'test'
          7        INIT_FCALL                                               'strtotime'
          8        SEND_VAL                                                 'tuesday'
          9        DO_ICALL                                         $2      
         10        SEND_VAR                                                 $2
         11        DO_FCALL                                      0          
   30    12        INIT_FCALL                                               'test'
         13        INIT_FCALL                                               'strtotime'
         14        SEND_VAL                                                 'wednesday'
         15        DO_ICALL                                         $4      
         16        SEND_VAR                                                 $4
         17        DO_FCALL                                      0          
   31    18        INIT_FCALL                                               'test'
         19        INIT_FCALL                                               'strtotime'
         20        SEND_VAL                                                 'thursday'
         21        DO_ICALL                                         $6      
         22        SEND_VAR                                                 $6
         23        DO_FCALL                                      0          
   32    24        INIT_FCALL                                               'test'
         25        INIT_FCALL                                               'strtotime'
         26        SEND_VAL                                                 'friday'
         27        DO_ICALL                                         $8      
         28        SEND_VAR                                                 $8
         29        DO_FCALL                                      0          
   33    30        INIT_FCALL                                               'test'
         31        INIT_FCALL                                               'strtotime'
         32        SEND_VAL                                                 'saturday'
         33        DO_ICALL                                         $10     
         34        SEND_VAR                                                 $10
         35        DO_FCALL                                      0          
   34    36        INIT_FCALL                                               'test'
         37        INIT_FCALL                                               'strtotime'
         38        SEND_VAL                                                 'sunday'
         39        DO_ICALL                                         $12     
         40        SEND_VAR                                                 $12
         41        DO_FCALL                                      0          
         42      > RETURN                                                   1

Function isactive:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tUV3B
function name:  isActive
number of ops:  13
compiled vars:  !0 = $date, !1 = $days, !2 = $week, !3 = $day
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        ASSIGN                                                   !1, <array>
   18     2        ASSIGN                                                   !2, 78
   19     3        INIT_FCALL                                               'date'
          4        SEND_VAL                                                 'N'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $6      
          7        FETCH_DIM_R                                      ~7      !1, $6
          8        ASSIGN                                                   !3, ~7
   20     9        BW_AND                                           ~9      !2, !3
         10        IS_IDENTICAL                                     ~10     !3, ~9
         11      > RETURN                                                   ~10
   21    12*     > RETURN                                                   null

End of function isactive

Function test:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tUV3B
function name:  test
number of ops:  18
compiled vars:  !0 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
   25     1        INIT_FCALL                                               'printf'
          2        SEND_VAL                                                 '%25s+is+%25s%0A'
          3        INIT_FCALL                                               'date'
          4        SEND_VAL                                                 'r'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $1      
          7        SEND_VAR                                                 $1
          8        INIT_FCALL                                               'isactive'
          9        SEND_VAR                                                 !0
         10        DO_FCALL                                      0  $2      
         11      > JMPZ                                                     $2, ->14
         12    >   QM_ASSIGN                                        ~3      'TRUE'
         13      > JMP                                                      ->15
         14    >   QM_ASSIGN                                        ~3      'FALSE'
         15    >   SEND_VAL                                                 ~3
         16        DO_ICALL                                                 
   27    17      > RETURN                                                   null

End of function test

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
301.51 ms | 1020 KiB | 24 Q