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{ $working_days=0; $total_days=0; while($begin<=$end){ $what_day=date("N",$begin); $total_days++; if($what_day<=5) { // 6 and 7 are weekend days $working_days++; }; $begin+=86400; // +1 day }; $testString = "working days: " . $working_days . " weekend days: " . ($total_days - $working_days); $testString = "working hours: " . ($working_days * 16); return $testString; } } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Z34el
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
   31    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 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 18
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 27
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 18
Branch analysis from position: 30
Branch analysis from position: 18
Branch analysis from position: 27
filename:       /in/Z34el
function name:  getWorkingDays
number of ops:  40
compiled vars:  !0 = $startDate, !1 = $endDate, !2 = $begin, !3 = $end, !4 = $working_days, !5 = $total_days, !6 = $what_day, !7 = $testString
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%3E'
   14    13      > RETURN                                                   0
         14*       JMP                                                      ->39
   16    15    >   ASSIGN                                                   !4, 0
   17    16        ASSIGN                                                   !5, 0
   18    17      > JMP                                                      ->28
   19    18    >   INIT_FCALL                                               'date'
         19        SEND_VAL                                                 'N'
         20        SEND_VAR                                                 !2
         21        DO_ICALL                                         $15     
         22        ASSIGN                                                   !6, $15
   20    23        PRE_INC                                                  !5
   21    24        IS_SMALLER_OR_EQUAL                                      !6, 5
         25      > JMPZ                                                     ~18, ->27
   22    26    >   PRE_INC                                                  !4
   24    27    >   ASSIGN_OP                                     1          !2, 86400
   18    28    >   IS_SMALLER_OR_EQUAL                                      !2, !3
         29      > JMPNZ                                                    ~21, ->18
   26    30    >   CONCAT                                           ~22     'working+days%3A+', !4
         31        CONCAT                                           ~23     ~22, '+weekend+days%3A+'
         32        SUB                                              ~24     !5, !4
         33        CONCAT                                           ~25     ~23, ~24
         34        ASSIGN                                                   !7, ~25
   27    35        MUL                                              ~27     !4, 16
         36        CONCAT                                           ~28     'working+hours%3A+', ~27
         37        ASSIGN                                                   !7, ~28
   28    38      > RETURN                                                   !7
   30    39*     > RETURN                                                   null

End of function getworkingdays

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.91 ms | 1392 KiB | 17 Q