3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isWeekend($date) { return $date->format('N') >= 6; } $daysOff = array(new \DateTime('2017-07-03'), new \DateTime('2017-07-04')); $periodStartDate = new \DateTime('today'); $periodStartDate = $periodStartDate->modify('-5 days'); $periodEndDate = new \DateTime('today'); $periodEndDate->modify('+1 day'); $period = new \DatePeriod($periodStartDate, \DateInterval::createFromDateString('1 day'), $periodEndDate); foreach ($period as $date) { echo $date->format('Y-m-d'); echo('\n'); if (/*$this->getDayOffInDaysOffByDate($daysOff, $date) ||*/ isWeekend($date)) { echo('minus'); } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 34, Position 2 = 46
Branch analysis from position: 34
2 jumps found. (Code = 78) Position 1 = 35, Position 2 = 46
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 45
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
Branch analysis from position: 45
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
filename:       /in/vXqpK
function name:  (null)
number of ops:  48
compiled vars:  !0 = $daysOff, !1 = $periodStartDate, !2 = $periodEndDate, !3 = $period, !4 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   NEW                                              $5      'DateTime'
          1        SEND_VAL_EX                                              '2017-07-03'
          2        DO_FCALL                                      0          
          3        INIT_ARRAY                                       ~7      $5
          4        NEW                                              $8      'DateTime'
          5        SEND_VAL_EX                                              '2017-07-04'
          6        DO_FCALL                                      0          
          7        ADD_ARRAY_ELEMENT                                ~7      $8
          8        ASSIGN                                                   !0, ~7
    8     9        NEW                                              $11     'DateTime'
         10        SEND_VAL_EX                                              'today'
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !1, $11
    9    13        INIT_METHOD_CALL                                         !1, 'modify'
         14        SEND_VAL_EX                                              '-5+days'
         15        DO_FCALL                                      0  $14     
         16        ASSIGN                                                   !1, $14
   10    17        NEW                                              $16     'DateTime'
         18        SEND_VAL_EX                                              'today'
         19        DO_FCALL                                      0          
         20        ASSIGN                                                   !2, $16
   11    21        INIT_METHOD_CALL                                         !2, 'modify'
         22        SEND_VAL_EX                                              '%2B1+day'
         23        DO_FCALL                                      0          
   12    24        NEW                                              $20     'DatePeriod'
         25        SEND_VAR_EX                                              !1
         26        INIT_STATIC_METHOD_CALL                                  'DateInterval', 'createFromDateString'
         27        SEND_VAL                                                 '1+day'
         28        DO_FCALL                                      0  $21     
         29        SEND_VAR_NO_REF_EX                                       $21
         30        SEND_VAR_EX                                              !2
         31        DO_FCALL                                      0          
         32        ASSIGN                                                   !3, $20
   14    33      > FE_RESET_R                                       $24     !3, ->46
         34    > > FE_FETCH_R                                               $24, !4, ->46
   15    35    >   INIT_METHOD_CALL                                         !4, 'format'
         36        SEND_VAL_EX                                              'Y-m-d'
         37        DO_FCALL                                      0  $25     
         38        ECHO                                                     $25
   16    39        ECHO                                                     '%5Cn'
   17    40        INIT_FCALL                                               'isweekend'
         41        SEND_VAR                                                 !4
         42        DO_FCALL                                      0  $26     
         43      > JMPZ                                                     $26, ->45
   18    44    >   ECHO                                                     'minus'
   14    45    > > JMP                                                      ->34
         46    >   FE_FREE                                                  $24
   20    47      > RETURN                                                   1

Function isweekend:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vXqpK
function name:  isWeekend
number of ops:  7
compiled vars:  !0 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        INIT_METHOD_CALL                                         !0, 'format'
          2        SEND_VAL_EX                                              'N'
          3        DO_FCALL                                      0  $1      
          4        IS_SMALLER_OR_EQUAL                              ~2      6, $1
          5      > RETURN                                                   ~2
    5     6*     > RETURN                                                   null

End of function isweekend

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.9 ms | 1407 KiB | 14 Q