3v4l.org

run code in 300+ PHP versions simultaneously
<?php $beginday=date('Y-m-01'); $lastday=date('Y-m-t'); $nr_work_days = getWorkingDays($beginday,$lastday); echo $nr_work_days; function getWorkingDays($startDate, $endDate){ $begin=strtotime($startDate); $end=strtotime($endDate); if($begin>$end){ echo "startdate is in the future! <br />"; return 0; }else{ $no_days=0; $weekends=0; $working_days=0; while($begin<=$end){ $no_days++; // no of days in the given interval $what_day=date("N",$begin); if($what_day<=5) { // 6 and 7 are weekend days $working_days++; }; $begin+=86400; // +1 day }; $working_days=$no_days-$weekends; return $working_days; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lYsE9
function name:  (null)
number of ops:  15
compiled vars:  !0 = $beginday, !1 = $lastday, !2 = $nr_work_days
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'date'
          1        SEND_VAL                                                 'Y-m-01'
          2        DO_ICALL                                         $3      
          3        ASSIGN                                                   !0, $3
    4     4        INIT_FCALL                                               'date'
          5        SEND_VAL                                                 'Y-m-t'
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !1, $5
    6     8        INIT_FCALL_BY_NAME                                       'getWorkingDays'
          9        SEND_VAR_EX                                              !0
         10        SEND_VAR_EX                                              !1
         11        DO_FCALL                                      0  $7      
         12        ASSIGN                                                   !2, $7
    7    13        ECHO                                                     !2
   30    14      > RETURN                                                   1

Function getworkingdays:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 19
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 28
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 19
Branch analysis from position: 31
Branch analysis from position: 19
Branch analysis from position: 28
filename:       /in/lYsE9
function name:  getWorkingDays
number of ops:  35
compiled vars:  !0 = $startDate, !1 = $endDate, !2 = $begin, !3 = $end, !4 = $no_days, !5 = $weekends, !6 = $working_days, !7 = $what_day
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        INIT_FCALL                                               'strtotime'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $8      
          5        ASSIGN                                                   !2, $8
   11     6        INIT_FCALL                                               'strtotime'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $10     
          9        ASSIGN                                                   !3, $10
   12    10        IS_SMALLER                                               !3, !2
         11      > JMPZ                                                     ~12, ->15
   13    12    >   ECHO                                                     'startdate+is+in+the+future%21+%3Cbr+%2F%3E'
   14    13      > RETURN                                                   0
         14*       JMP                                                      ->34
   16    15    >   ASSIGN                                                   !4, 0
   17    16        ASSIGN                                                   !5, 0
   18    17        ASSIGN                                                   !6, 0
   19    18      > JMP                                                      ->29
   20    19    >   PRE_INC                                                  !4
   21    20        INIT_FCALL                                               'date'
         21        SEND_VAL                                                 'N'
         22        SEND_VAR                                                 !2
         23        DO_ICALL                                         $17     
         24        ASSIGN                                                   !7, $17
   22    25        IS_SMALLER_OR_EQUAL                                      !7, 5
         26      > JMPZ                                                     ~19, ->28
   23    27    >   PRE_INC                                                  !6
   25    28    >   ASSIGN_OP                                     1          !2, 86400
   19    29    >   IS_SMALLER_OR_EQUAL                                      !2, !3
         30      > JMPNZ                                                    ~22, ->19
   27    31    >   SUB                                              ~23     !4, !5
         32        ASSIGN                                                   !6, ~23
   28    33      > RETURN                                                   !6
   30    34*     > RETURN                                                   null

End of function getworkingdays

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
182.07 ms | 1400 KiB | 17 Q