3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @param \DateTime $date Date of the original meeting * @return \DateTime Date of the next meeting */ function getSameDayLastYear(\DateTime $date = null) { if(!$date){ $date = new \DateTime(); } return (new \DateTime())->setISODate((int)$date->format('o') - 1, (int)$date->format('W'), (int)$date->format('N')); } $start = new \DateTime(); $end = new \DateTime('+4 years'); $interval = new \DateInterval('P1D'); $period = new \DatePeriod($start, $interval, $end); $format = 'Y-m-d'; echo "insert ignore into TblDatesDev (date, lastYear) VALUES \n"; foreach($period as $date){ echo "('".$date->format($format)."','".getSameDayLastYear($date)->format($format)."'),\n"; //echo $date->format($format) . ' => ' . getSameDayLastYear($date)->format($format) . "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 36
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 36
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
filename:       /in/t7aPp
function name:  (null)
number of ops:  38
compiled vars:  !0 = $start, !1 = $end, !2 = $interval, !3 = $period, !4 = $format, !5 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   NEW                                              $6      'DateTime'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $6
   15     3        NEW                                              $9      'DateTime'
          4        SEND_VAL_EX                                              '%2B4+years'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $9
   16     7        NEW                                              $12     'DateInterval'
          8        SEND_VAL_EX                                              'P1D'
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $12
   17    11        NEW                                              $15     'DatePeriod'
         12        SEND_VAR_EX                                              !0
         13        SEND_VAR_EX                                              !2
         14        SEND_VAR_EX                                              !1
         15        DO_FCALL                                      0          
         16        ASSIGN                                                   !3, $15
   18    17        ASSIGN                                                   !4, 'Y-m-d'
   19    18        ECHO                                                     'insert+ignore+into+TblDatesDev+%28date%2C+lastYear%29+VALUES+%0A'
   20    19      > FE_RESET_R                                       $19     !3, ->36
         20    > > FE_FETCH_R                                               $19, !5, ->36
   21    21    >   INIT_METHOD_CALL                                         !5, 'format'
         22        SEND_VAR_EX                                              !4
         23        DO_FCALL                                      0  $20     
         24        CONCAT                                           ~21     '%28%27', $20
         25        CONCAT                                           ~22     ~21, '%27%2C%27'
         26        INIT_FCALL                                               'getsamedaylastyear'
         27        SEND_VAR                                                 !5
         28        DO_FCALL                                      0  $23     
         29        INIT_METHOD_CALL                                         $23, 'format'
         30        SEND_VAR_EX                                              !4
         31        DO_FCALL                                      0  $24     
         32        CONCAT                                           ~25     ~22, $24
         33        CONCAT                                           ~26     ~25, '%27%29%2C%0A'
         34        ECHO                                                     ~26
   20    35      > JMP                                                      ->20
         36    >   FE_FREE                                                  $19
   23    37      > RETURN                                                   1

Function getsamedaylastyear:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/t7aPp
function name:  getSameDayLastYear
number of ops:  28
compiled vars:  !0 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV_INIT                                        !0      null
    8     1        BOOL_NOT                                         ~1      !0
          2      > JMPZ                                                     ~1, ->6
    9     3    >   NEW                                              $2      'DateTime'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $2
   11     6    >   NEW                                              $5      'DateTime'
          7        DO_FCALL                                      0          
          8        INIT_METHOD_CALL                                         $5, 'setISODate'
          9        INIT_METHOD_CALL                                         !0, 'format'
         10        SEND_VAL_EX                                              'o'
         11        DO_FCALL                                      0  $7      
         12        CAST                                          4  ~8      $7
         13        SUB                                              ~9      ~8, 1
         14        SEND_VAL_EX                                              ~9
         15        INIT_METHOD_CALL                                         !0, 'format'
         16        SEND_VAL_EX                                              'W'
         17        DO_FCALL                                      0  $10     
         18        CAST                                          4  ~11     $10
         19        SEND_VAL_EX                                              ~11
         20        INIT_METHOD_CALL                                         !0, 'format'
         21        SEND_VAL_EX                                              'N'
         22        DO_FCALL                                      0  $12     
         23        CAST                                          4  ~13     $12
         24        SEND_VAL_EX                                              ~13
         25        DO_FCALL                                      0  $14     
         26      > RETURN                                                   $14
   12    27*     > RETURN                                                   null

End of function getsamedaylastyear

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
194.41 ms | 1403 KiB | 14 Q