3v4l.org

run code in 300+ PHP versions simultaneously
<?php function week_date($weeks = 0) { $start = new DateTime("monday this week"); $end = new DateTime(); $start->modify("$weeks weeks"); $end->modify("$weeks weeks"); return $start->format('Y-m-d') . ' ' . $end->format('Y-m-d'); } echo week_date() . "\n"; // this week echo week_date(-1) . "\n"; // last week echo week_date(1) . "\n"; // next week
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0lcP3
function name:  (null)
number of ops:  15
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                               'week_date'
          1        DO_FCALL                                      0  $0      
          2        CONCAT                                           ~1      $0, '%0A'
          3        ECHO                                                     ~1
   11     4        INIT_FCALL                                               'week_date'
          5        SEND_VAL                                                 -1
          6        DO_FCALL                                      0  $2      
          7        CONCAT                                           ~3      $2, '%0A'
          8        ECHO                                                     ~3
   12     9        INIT_FCALL                                               'week_date'
         10        SEND_VAL                                                 1
         11        DO_FCALL                                      0  $4      
         12        CONCAT                                           ~5      $4, '%0A'
         13        ECHO                                                     ~5
         14      > RETURN                                                   1

Function week_date:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0lcP3
function name:  week_date
number of ops:  28
compiled vars:  !0 = $weeks, !1 = $start, !2 = $end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV_INIT                                        !0      0
    4     1        NEW                                              $3      'DateTime'
          2        SEND_VAL_EX                                              'monday+this+week'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $3
    5     5        NEW                                              $6      'DateTime'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !2, $6
    6     8        INIT_METHOD_CALL                                         !1, 'modify'
          9        NOP                                                      
         10        FAST_CONCAT                                      ~9      !0, '+weeks'
         11        SEND_VAL_EX                                              ~9
         12        DO_FCALL                                      0          
    7    13        INIT_METHOD_CALL                                         !2, 'modify'
         14        NOP                                                      
         15        FAST_CONCAT                                      ~11     !0, '+weeks'
         16        SEND_VAL_EX                                              ~11
         17        DO_FCALL                                      0          
    8    18        INIT_METHOD_CALL                                         !1, 'format'
         19        SEND_VAL_EX                                              'Y-m-d'
         20        DO_FCALL                                      0  $13     
         21        CONCAT                                           ~14     $13, '+'
         22        INIT_METHOD_CALL                                         !2, 'format'
         23        SEND_VAL_EX                                              'Y-m-d'
         24        DO_FCALL                                      0  $15     
         25        CONCAT                                           ~16     ~14, $15
         26      > RETURN                                                   ~16
    9    27*     > RETURN                                                   null

End of function week_date

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.11 ms | 950 KiB | 16 Q