3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Mutable $today = new DateTime; $yesterday = $today->sub(new DateInterval('P1D')); // subtract one day $tomorrow = $today->add(new DateInterval('P1D')); // add one day // $today, $yesterday and $tomorrow are all the same date! 🤯 echo "Today is ".$today->format('Y-m-d'). "\n"; echo "Yesterday is ".$yesterday->format('Y-m-d'). "\n"; echo "Tomorrow is ".$tomorrow->format('Y-m-d'). "\n"; // Immutable $today = new DateTimeImmutable; $yesterday = $today->sub(new DateInterval('P1D')); // subtract one day $tomorrow = $today->add(new DateInterval('P1D')); // add one day // $today, $yesterday and $tomorrow are all the same date! 🤯 echo "With DateTimeImmutable: Today is ".$today->format('Y-m-d'). "\n"; echo "With DateTimeImmutable: Yesterday is ".$yesterday->format('Y-m-d'). "\n"; echo "With DateTimeImmutable: Tomorrow is ".$tomorrow->format('Y-m-d'). "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PQoan
function name:  (null)
number of ops:  71
compiled vars:  !0 = $today, !1 = $yesterday, !2 = $tomorrow
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   NEW                                              $3      'DateTime'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
    5     3        INIT_METHOD_CALL                                         !0, 'sub'
          4        NEW                                              $6      'DateInterval'
          5        SEND_VAL_EX                                              'P1D'
          6        DO_FCALL                                      0          
          7        SEND_VAR_NO_REF_EX                                       $6
          8        DO_FCALL                                      0  $8      
          9        ASSIGN                                                   !1, $8
    6    10        INIT_METHOD_CALL                                         !0, 'add'
         11        NEW                                              $10     'DateInterval'
         12        SEND_VAL_EX                                              'P1D'
         13        DO_FCALL                                      0          
         14        SEND_VAR_NO_REF_EX                                       $10
         15        DO_FCALL                                      0  $12     
         16        ASSIGN                                                   !2, $12
    9    17        INIT_METHOD_CALL                                         !0, 'format'
         18        SEND_VAL_EX                                              'Y-m-d'
         19        DO_FCALL                                      0  $14     
         20        CONCAT                                           ~15     'Today+is+', $14
         21        CONCAT                                           ~16     ~15, '%0A'
         22        ECHO                                                     ~16
   10    23        INIT_METHOD_CALL                                         !1, 'format'
         24        SEND_VAL_EX                                              'Y-m-d'
         25        DO_FCALL                                      0  $17     
         26        CONCAT                                           ~18     'Yesterday+is+', $17
         27        CONCAT                                           ~19     ~18, '%0A'
         28        ECHO                                                     ~19
   11    29        INIT_METHOD_CALL                                         !2, 'format'
         30        SEND_VAL_EX                                              'Y-m-d'
         31        DO_FCALL                                      0  $20     
         32        CONCAT                                           ~21     'Tomorrow+is+', $20
         33        CONCAT                                           ~22     ~21, '%0A'
         34        ECHO                                                     ~22
   14    35        NEW                                              $23     'DateTimeImmutable'
         36        DO_FCALL                                      0          
         37        ASSIGN                                                   !0, $23
   15    38        INIT_METHOD_CALL                                         !0, 'sub'
         39        NEW                                              $26     'DateInterval'
         40        SEND_VAL_EX                                              'P1D'
         41        DO_FCALL                                      0          
         42        SEND_VAR_NO_REF_EX                                       $26
         43        DO_FCALL                                      0  $28     
         44        ASSIGN                                                   !1, $28
   16    45        INIT_METHOD_CALL                                         !0, 'add'
         46        NEW                                              $30     'DateInterval'
         47        SEND_VAL_EX                                              'P1D'
         48        DO_FCALL                                      0          
         49        SEND_VAR_NO_REF_EX                                       $30
         50        DO_FCALL                                      0  $32     
         51        ASSIGN                                                   !2, $32
   19    52        INIT_METHOD_CALL                                         !0, 'format'
         53        SEND_VAL_EX                                              'Y-m-d'
         54        DO_FCALL                                      0  $34     
         55        CONCAT                                           ~35     'With+DateTimeImmutable%3A+Today+is+', $34
         56        CONCAT                                           ~36     ~35, '%0A'
         57        ECHO                                                     ~36
   20    58        INIT_METHOD_CALL                                         !1, 'format'
         59        SEND_VAL_EX                                              'Y-m-d'
         60        DO_FCALL                                      0  $37     
         61        CONCAT                                           ~38     'With+DateTimeImmutable%3A+Yesterday+is+', $37
         62        CONCAT                                           ~39     ~38, '%0A'
         63        ECHO                                                     ~39
   21    64        INIT_METHOD_CALL                                         !2, 'format'
         65        SEND_VAL_EX                                              'Y-m-d'
         66        DO_FCALL                                      0  $40     
         67        CONCAT                                           ~41     'With+DateTimeImmutable%3A+Tomorrow+is+', $40
         68        CONCAT                                           ~42     ~41, '%0A'
         69        ECHO                                                     ~42
         70      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
125.48 ms | 1447 KiB | 13 Q