3v4l.org

run code in 500+ PHP versions simultaneously
<?php function add_one_month($date) { // find the next month $nextmonth = mktime(0, 0, 0, date("n", $date) + 1, 1, date("Y", $date)); // limit the day number according to the month $day = min(date("t", $nextmonth), date("j", $date)); // combine into desired date return mktime(0, 0, 0, date("n", $nextmonth), $day, date("Y", $nextmonth)); } for ($d = 20; $d <= 31; $d++) { $date = mktime(0, 0, 0, 1, $d, 2017); $normal = date("Y-m-d", strtotime("+1 month", $date)); $addonemonth = date("Y-m-d", add_one_month($date)); printf("2017-01-%02d: +1 month = %s add_one_month = %s\n", $d, $normal, $addonemonth); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 2
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 2
Branch analysis from position: 37
Branch analysis from position: 2
filename:       /in/SjYiE
function name:  (null)
number of ops:  38
compiled vars:  !0 = $d, !1 = $date, !2 = $normal, !3 = $addonemonth
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   ASSIGN                                                       !0, 20
          1      > JMP                                                          ->35
   13     2    >   INIT_FCALL                                                   'mktime'
          3        SEND_VAL                                                     0
          4        SEND_VAL                                                     0
          5        SEND_VAL                                                     0
          6        SEND_VAL                                                     1
          7        SEND_VAR                                                     !0
          8        SEND_VAL                                                     2017
          9        DO_ICALL                                             $5      
         10        ASSIGN                                                       !1, $5
   14    11        INIT_FCALL                                                   'date'
         12        SEND_VAL                                                     'Y-m-d'
         13        INIT_FCALL                                                   'strtotime'
         14        SEND_VAL                                                     '%2B1+month'
         15        SEND_VAR                                                     !1
         16        DO_ICALL                                             $7      
         17        SEND_VAR                                                     $7
         18        DO_ICALL                                             $8      
         19        ASSIGN                                                       !2, $8
   15    20        INIT_FCALL                                                   'date'
         21        SEND_VAL                                                     'Y-m-d'
         22        INIT_FCALL                                                   'add_one_month'
         23        SEND_VAR                                                     !1
         24        DO_FCALL                                          0  $10     
         25        SEND_VAR                                                     $10
         26        DO_ICALL                                             $11     
         27        ASSIGN                                                       !3, $11
   16    28        INIT_FCALL                                                   'printf'
         29        SEND_VAL                                                     '2017-01-%2502d%3A++%2B1+month+%3D+%25s++add_one_month+%3D+%25s%0A'
         30        SEND_VAR                                                     !0
         31        SEND_VAR                                                     !2
         32        SEND_VAR                                                     !3
         33        DO_ICALL                                                     
   12    34        PRE_INC                                                      !0
         35    >   IS_SMALLER_OR_EQUAL                                          !0, 31
         36      > JMPNZ                                                        ~15, ->2
   17    37    > > RETURN                                                       1

Function add_one_month:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SjYiE
function name:  add_one_month
number of ops:  47
compiled vars:  !0 = $date, !1 = $nextmonth, !2 = $day
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    5     1        INIT_FCALL                                                   'mktime'
          2        SEND_VAL                                                     0
          3        SEND_VAL                                                     0
          4        SEND_VAL                                                     0
          5        INIT_FCALL                                                   'date'
          6        SEND_VAL                                                     'n'
          7        SEND_VAR                                                     !0
          8        DO_ICALL                                             $3      
          9        ADD                                                  ~4      $3, 1
         10        SEND_VAL                                                     ~4
         11        SEND_VAL                                                     1
         12        INIT_FCALL                                                   'date'
         13        SEND_VAL                                                     'Y'
         14        SEND_VAR                                                     !0
         15        DO_ICALL                                             $5      
         16        SEND_VAR                                                     $5
         17        DO_ICALL                                             $6      
         18        ASSIGN                                                       !1, $6
    7    19        INIT_FCALL                                                   'date'
         20        SEND_VAL                                                     't'
         21        SEND_VAR                                                     !1
         22        DO_ICALL                                             $8      
         23        INIT_FCALL                                                   'date'
         24        SEND_VAL                                                     'j'
         25        SEND_VAR                                                     !0
         26        DO_ICALL                                             $9      
         27        FRAMELESS_ICALL_2                min                 ~10     $8, $9
         28        ASSIGN                                                       !2, ~10
    9    29        INIT_FCALL                                                   'mktime'
         30        SEND_VAL                                                     0
         31        SEND_VAL                                                     0
         32        SEND_VAL                                                     0
         33        INIT_FCALL                                                   'date'
         34        SEND_VAL                                                     'n'
         35        SEND_VAR                                                     !1
         36        DO_ICALL                                             $12     
         37        SEND_VAR                                                     $12
         38        SEND_VAR                                                     !2
         39        INIT_FCALL                                                   'date'
         40        SEND_VAL                                                     'Y'
         41        SEND_VAR                                                     !1
         42        DO_ICALL                                             $13     
         43        SEND_VAR                                                     $13
         44        DO_ICALL                                             $14     
         45      > RETURN                                                       $14
   10    46*     > RETURN                                                       null

End of function add_one_month

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
165.92 ms | 2844 KiB | 18 Q