3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getWeeksInMonth($weekStartDay = 0) { $date = new \Datetime('2015-03-01'); // Total number of days in the given month.; $numberOfDays = $date->format("t"); // Count the number of times it hits $weekStartDay. $numberOfWeeks = 1; for ($i = 1; $i <= $numberOfDays; $i++) { $nextDay = $date->add(new \DateInterval('P1D')); $dayOfWeek = $nextDay->format('w'); if ($dayOfWeek == $weekStartDay) { $numberOfWeeks++; } } return $numberOfWeeks; } echo getWeeksInMonth();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NEdCh
function name:  (null)
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   INIT_FCALL                                               'getweeksinmonth'
          1        DO_FCALL                                      0  $0      
          2        ECHO                                                     $0
          3      > RETURN                                                   1

Function getweeksinmonth:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 12
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 26
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 12
Branch analysis from position: 29
Branch analysis from position: 12
Branch analysis from position: 26
filename:       /in/NEdCh
function name:  getWeeksInMonth
number of ops:  31
compiled vars:  !0 = $weekStartDay, !1 = $date, !2 = $numberOfDays, !3 = $numberOfWeeks, !4 = $i, !5 = $nextDay, !6 = $dayOfWeek
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV_INIT                                        !0      0
    5     1        NEW                                              $7      'Datetime'
          2        SEND_VAL_EX                                              '2015-03-01'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $7
    7     5        INIT_METHOD_CALL                                         !1, 'format'
          6        SEND_VAL_EX                                              't'
          7        DO_FCALL                                      0  $10     
          8        ASSIGN                                                   !2, $10
   10     9        ASSIGN                                                   !3, 1
   11    10        ASSIGN                                                   !4, 1
         11      > JMP                                                      ->27
   12    12    >   INIT_METHOD_CALL                                         !1, 'add'
         13        NEW                                              $14     'DateInterval'
         14        SEND_VAL_EX                                              'P1D'
         15        DO_FCALL                                      0          
         16        SEND_VAR_NO_REF_EX                                       $14
         17        DO_FCALL                                      0  $16     
         18        ASSIGN                                                   !5, $16
   16    19        INIT_METHOD_CALL                                         !5, 'format'
         20        SEND_VAL_EX                                              'w'
         21        DO_FCALL                                      0  $18     
         22        ASSIGN                                                   !6, $18
   18    23        IS_EQUAL                                                 !6, !0
         24      > JMPZ                                                     ~20, ->26
   19    25    >   PRE_INC                                                  !3
   11    26    >   PRE_INC                                                  !4
         27    >   IS_SMALLER_OR_EQUAL                                      !4, !2
         28      > JMPNZ                                                    ~23, ->12
   25    29    > > RETURN                                                   !3
   26    30*     > RETURN                                                   null

End of function getweeksinmonth

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.35 ms | 1403 KiB | 14 Q