3v4l.org

run code in 300+ 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:  50
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                                               'min'
         20        INIT_FCALL                                               'date'
         21        SEND_VAL                                                 't'
         22        SEND_VAR                                                 !1
         23        DO_ICALL                                         $8      
         24        SEND_VAR                                                 $8
         25        INIT_FCALL                                               'date'
         26        SEND_VAL                                                 'j'
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                         $9      
         29        SEND_VAR                                                 $9
         30        DO_ICALL                                         $10     
         31        ASSIGN                                                   !2, $10
    9    32        INIT_FCALL                                               'mktime'
         33        SEND_VAL                                                 0
         34        SEND_VAL                                                 0
         35        SEND_VAL                                                 0
         36        INIT_FCALL                                               'date'
         37        SEND_VAL                                                 'n'
         38        SEND_VAR                                                 !1
         39        DO_ICALL                                         $12     
         40        SEND_VAR                                                 $12
         41        SEND_VAR                                                 !2
         42        INIT_FCALL                                               'date'
         43        SEND_VAL                                                 'Y'
         44        SEND_VAR                                                 !1
         45        DO_ICALL                                         $13     
         46        SEND_VAR                                                 $13
         47        DO_ICALL                                         $14     
         48      > RETURN                                                   $14
   10    49*     > RETURN                                                   null

End of function add_one_month

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.45 ms | 1013 KiB | 19 Q