3v4l.org

run code in 300+ PHP versions simultaneously
<?php function printLastDateInPeriod($startDate, $endDate) { $period = iterator_to_array(new DatePeriod( new DateTime($startDate), new DateInterval('P1D'), new DateTime($endDate) )); echo $startDate->format('Y-m-d H:i:s') . PHP_EOL; echo str_pad("$startDate <-> $endDate: ", 30).end($period)->format('Y-m-d').PHP_EOL; } printLastDateInPeriod('-1 week', 'now'); printLastDateInPeriod('-1 week', 'today'); printLastDateInPeriod('2014-11-10', 'now'); printLastDateInPeriod('2014-11-10', 'today');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uehQl
function name:  (null)
number of ops:  17
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_FCALL                                               'printlastdateinperiod'
          1        SEND_VAL                                                 '-1+week'
          2        SEND_VAL                                                 'now'
          3        DO_FCALL                                      0          
   16     4        INIT_FCALL                                               'printlastdateinperiod'
          5        SEND_VAL                                                 '-1+week'
          6        SEND_VAL                                                 'today'
          7        DO_FCALL                                      0          
   18     8        INIT_FCALL                                               'printlastdateinperiod'
          9        SEND_VAL                                                 '2014-11-10'
         10        SEND_VAL                                                 'now'
         11        DO_FCALL                                      0          
   19    12        INIT_FCALL                                               'printlastdateinperiod'
         13        SEND_VAL                                                 '2014-11-10'
         14        SEND_VAL                                                 'today'
         15        DO_FCALL                                      0          
         16      > RETURN                                                   1

Function printlastdateinperiod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uehQl
function name:  printLastDateInPeriod
number of ops:  43
compiled vars:  !0 = $startDate, !1 = $endDate, !2 = $period
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        INIT_FCALL                                               'iterator_to_array'
          3        NEW                                              $3      'DatePeriod'
    6     4        NEW                                              $4      'DateTime'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
          7        SEND_VAR_NO_REF_EX                                       $4
    7     8        NEW                                              $6      'DateInterval'
          9        SEND_VAL_EX                                              'P1D'
         10        DO_FCALL                                      0          
         11        SEND_VAR_NO_REF_EX                                       $6
    8    12        NEW                                              $8      'DateTime'
         13        SEND_VAR_EX                                              !1
         14        DO_FCALL                                      0          
         15        SEND_VAR_NO_REF_EX                                       $8
         16        DO_FCALL                                      0          
         17        SEND_VAR                                                 $3
         18        DO_ICALL                                         $11     
    5    19        ASSIGN                                                   !2, $11
   11    20        INIT_METHOD_CALL                                         !0, 'format'
         21        SEND_VAL_EX                                              'Y-m-d+H%3Ai%3As'
         22        DO_FCALL                                      0  $13     
         23        CONCAT                                           ~14     $13, '%0A'
         24        ECHO                                                     ~14
   12    25        INIT_FCALL                                               'str_pad'
         26        ROPE_INIT                                     4  ~16     !0
         27        ROPE_ADD                                      1  ~16     ~16, '+%3C-%3E+'
         28        ROPE_ADD                                      2  ~16     ~16, !1
         29        ROPE_END                                      3  ~15     ~16, '%3A+'
         30        SEND_VAL                                                 ~15
         31        SEND_VAL                                                 30
         32        DO_ICALL                                         $18     
         33        INIT_FCALL                                               'end'
         34        SEND_REF                                                 !2
         35        DO_ICALL                                         $19     
         36        INIT_METHOD_CALL                                         $19, 'format'
         37        SEND_VAL_EX                                              'Y-m-d'
         38        DO_FCALL                                      0  $20     
         39        CONCAT                                           ~21     $18, $20
         40        CONCAT                                           ~22     ~21, '%0A'
         41        ECHO                                                     ~22
   13    42      > RETURN                                                   null

End of function printlastdateinperiod

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.08 ms | 1403 KiB | 23 Q