3v4l.org

run code in 300+ PHP versions simultaneously
<?php $givenday = mktime(0,0,0,01,01,2013); $Monday = strtotime("Monday this week",$givenday); echo date("j M Y H:i:s", $Monday); function StartOfWeek($year, $week) { $Jan1 = mktime(1,1,1,1,1,$year); $MondayOffset = (11-date('w',$Jan1))%7-3; $desiredMonday = strtotime(($week-1) . ' weeks '.$MondayOffset.' days', $Jan1); return $desiredMonday; } echo StartOfWeek(2013, 1);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6LLY0
function name:  (null)
number of ops:  25
compiled vars:  !0 = $givenday, !1 = $Monday
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'mktime'
          1        SEND_VAL                                                 0
          2        SEND_VAL                                                 0
          3        SEND_VAL                                                 0
          4        SEND_VAL                                                 1
          5        SEND_VAL                                                 1
          6        SEND_VAL                                                 2013
          7        DO_ICALL                                         $2      
          8        ASSIGN                                                   !0, $2
    4     9        INIT_FCALL                                               'strtotime'
         10        SEND_VAL                                                 'Monday+this+week'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $4      
         13        ASSIGN                                                   !1, $4
    5    14        INIT_FCALL                                               'date'
         15        SEND_VAL                                                 'j+M+Y+H%3Ai%3As'
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                         $6      
         18        ECHO                                                     $6
   15    19        INIT_FCALL                                               'startofweek'
         20        SEND_VAL                                                 2013
         21        SEND_VAL                                                 1
         22        DO_FCALL                                      0  $7      
         23        ECHO                                                     $7
         24      > RETURN                                                   1

Function startofweek:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6LLY0
function name:  StartOfWeek
number of ops:  30
compiled vars:  !0 = $year, !1 = $week, !2 = $Jan1, !3 = $MondayOffset, !4 = $desiredMonday
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        INIT_FCALL                                               'mktime'
          3        SEND_VAL                                                 1
          4        SEND_VAL                                                 1
          5        SEND_VAL                                                 1
          6        SEND_VAL                                                 1
          7        SEND_VAL                                                 1
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $5      
         10        ASSIGN                                                   !2, $5
   11    11        INIT_FCALL                                               'date'
         12        SEND_VAL                                                 'w'
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                         $7      
         15        SUB                                              ~8      11, $7
         16        MOD                                              ~9      ~8, 7
         17        SUB                                              ~10     ~9, 3
         18        ASSIGN                                                   !3, ~10
   12    19        INIT_FCALL                                               'strtotime'
         20        SUB                                              ~12     !1, 1
         21        CONCAT                                           ~13     ~12, '+weeks+'
         22        CONCAT                                           ~14     ~13, !3
         23        CONCAT                                           ~15     ~14, '+days'
         24        SEND_VAL                                                 ~15
         25        SEND_VAR                                                 !2
         26        DO_ICALL                                         $16     
         27        ASSIGN                                                   !4, $16
   13    28      > RETURN                                                   !4
   14    29*     > RETURN                                                   null

End of function startofweek

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.85 ms | 1407 KiB | 20 Q