3v4l.org

run code in 300+ PHP versions simultaneously
<?php function oneWeek(\DateTimeInterface $date): \DateTimeInterface { $week = new \DateInterval('P1W'); $inOneWeek = $date->add($week); return $inOneWeek; } $d1 = new \DateTime(); $d2 = new \DateTimeImmutable(); $o1 = oneWeek($d1); $o2 = oneWeek($d2); $f = 'F jS, Y'; echo 'One week from ' . $d1->format($f) . ' is ' . $o1->format($f) . "\n"; echo 'One week from ' . $d2->format($f) . ' is ' . $o2->format($f) . "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/X0pJg
function name:  (null)
number of ops:  38
compiled vars:  !0 = $d1, !1 = $d2, !2 = $o1, !3 = $o2, !4 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   NEW                                              $5      'DateTime'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $5
   11     3        NEW                                              $8      'DateTimeImmutable'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $8
   13     6        INIT_FCALL                                               'oneweek'
          7        SEND_VAR                                                 !0
          8        DO_FCALL                                      0  $11     
          9        ASSIGN                                                   !2, $11
   14    10        INIT_FCALL                                               'oneweek'
         11        SEND_VAR                                                 !1
         12        DO_FCALL                                      0  $13     
         13        ASSIGN                                                   !3, $13
   16    14        ASSIGN                                                   !4, 'F+jS%2C+Y'
   17    15        INIT_METHOD_CALL                                         !0, 'format'
         16        SEND_VAR_EX                                              !4
         17        DO_FCALL                                      0  $16     
         18        CONCAT                                           ~17     'One+week+from+', $16
         19        CONCAT                                           ~18     ~17, '+is+'
         20        INIT_METHOD_CALL                                         !2, 'format'
         21        SEND_VAR_EX                                              !4
         22        DO_FCALL                                      0  $19     
         23        CONCAT                                           ~20     ~18, $19
         24        CONCAT                                           ~21     ~20, '%0A'
         25        ECHO                                                     ~21
   18    26        INIT_METHOD_CALL                                         !1, 'format'
         27        SEND_VAR_EX                                              !4
         28        DO_FCALL                                      0  $22     
         29        CONCAT                                           ~23     'One+week+from+', $22
         30        CONCAT                                           ~24     ~23, '+is+'
         31        INIT_METHOD_CALL                                         !3, 'format'
         32        SEND_VAR_EX                                              !4
         33        DO_FCALL                                      0  $25     
         34        CONCAT                                           ~26     ~24, $25
         35        CONCAT                                           ~27     ~26, '%0A'
         36        ECHO                                                     ~27
         37      > RETURN                                                   1

Function oneweek:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/X0pJg
function name:  oneWeek
number of ops:  13
compiled vars:  !0 = $date, !1 = $week, !2 = $inOneWeek
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        NEW                                              $3      'DateInterval'
          2        SEND_VAL_EX                                              'P1W'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $3
    6     5        INIT_METHOD_CALL                                         !0, 'add'
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0  $6      
          8        ASSIGN                                                   !2, $6
    7     9        VERIFY_RETURN_TYPE                                       !2
         10      > RETURN                                                   !2
    8    11*       VERIFY_RETURN_TYPE                                       
         12*     > RETURN                                                   null

End of function oneweek

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.94 ms | 1011 KiB | 15 Q