3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getLastMonth(DateTime $date) { //avoid side affects $date = clone $date; $date->modify('first day of last month'); return array( $date->format('Y-m-d'), $date->format('Y-m-t'), ); } list($start, $end) = getLastMonth(new \DateTime()); var_dump($start, $end);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8v8C4
function name:  (null)
number of ops:  15
compiled vars:  !0 = $start, !1 = $end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                               'getlastmonth'
          1        NEW                                              $2      'DateTime'
          2        DO_FCALL                                      0          
          3        SEND_VAR                                                 $2
          4        DO_FCALL                                      0  $4      
          5        FETCH_LIST_R                                     $5      $4, 0
          6        ASSIGN                                                   !0, $5
          7        FETCH_LIST_R                                     $7      $4, 1
          8        ASSIGN                                                   !1, $7
          9        FREE                                                     $4
   14    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !0
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function getlastmonth:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8v8C4
function name:  getLastMonth
number of ops:  16
compiled vars:  !0 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    5     1        CLONE                                            ~1      !0
          2        ASSIGN                                                   !0, ~1
    6     3        INIT_METHOD_CALL                                         !0, 'modify'
          4        SEND_VAL_EX                                              'first+day+of+last+month'
          5        DO_FCALL                                      0          
    8     6        INIT_METHOD_CALL                                         !0, 'format'
          7        SEND_VAL_EX                                              'Y-m-d'
          8        DO_FCALL                                      0  $4      
          9        INIT_ARRAY                                       ~5      $4
    9    10        INIT_METHOD_CALL                                         !0, 'format'
         11        SEND_VAL_EX                                              'Y-m-t'
         12        DO_FCALL                                      0  $6      
         13        ADD_ARRAY_ELEMENT                                ~5      $6
         14      > RETURN                                                   ~5
   11    15*     > RETURN                                                   null

End of function getlastmonth

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.78 ms | 1399 KiB | 16 Q