3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getTimeRange($month) { $month = str_pad($month, 2, '0', STR_PAD_LEFT); $year = $month > date('m') ? date('Y') - 1 : date('Y'); $start_date = "{$year}-{$month}-01"; $end_date = date('Y-m-d', strtotime("+1 month", strtotime($start_date))); return array( 'start_date' => $start_date, 'end_date' => $end_date ); } function getTimeRange2($month, $year = 0) { $month = str_pad($month, 2, '0', STR_PAD_LEFT); $year = ($year ? : ($month > date('m') ? date('Y') - 1 : date('Y'))); $res = array( 'start_date' => "{$year}-{$month}-01", 'end_date' => date('Y-m-d', strtotime("+1 month", strtotime($res['start_date']))) ); return $res; } var_dump(getTimeRange(1)); var_dump(getTimeRange2(1));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Z68l9
function name:  (null)
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'gettimerange'
          2        SEND_VAL                                                 1
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
   26     6        INIT_FCALL                                               'var_dump'
          7        INIT_FCALL                                               'gettimerange2'
          8        SEND_VAL                                                 1
          9        DO_FCALL                                      0  $2      
         10        SEND_VAR                                                 $2
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Function gettimerange:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 19
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Z68l9
function name:  getTimeRange
number of ops:  45
compiled vars:  !0 = $month, !1 = $year, !2 = $start_date, !3 = $end_date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'str_pad'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 2
          4        SEND_VAL                                                 '0'
          5        SEND_VAL                                                 0
          6        DO_ICALL                                         $4      
          7        ASSIGN                                                   !0, $4
    6     8        INIT_FCALL                                               'date'
          9        SEND_VAL                                                 'm'
         10        DO_ICALL                                         $6      
         11        IS_SMALLER                                               $6, !0
         12      > JMPZ                                                     ~7, ->19
         13    >   INIT_FCALL                                               'date'
         14        SEND_VAL                                                 'Y'
         15        DO_ICALL                                         $8      
         16        SUB                                              ~9      $8, 1
         17        QM_ASSIGN                                        ~10     ~9
         18      > JMP                                                      ->23
         19    >   INIT_FCALL                                               'date'
         20        SEND_VAL                                                 'Y'
         21        DO_ICALL                                         $11     
         22        QM_ASSIGN                                        ~10     $11
         23    >   ASSIGN                                                   !1, ~10
    7    24        ROPE_INIT                                     4  ~14     !1
         25        ROPE_ADD                                      1  ~14     ~14, '-'
         26        ROPE_ADD                                      2  ~14     ~14, !0
         27        ROPE_END                                      3  ~13     ~14, '-01'
         28        ASSIGN                                                   !2, ~13
    8    29        INIT_FCALL                                               'date'
         30        SEND_VAL                                                 'Y-m-d'
         31        INIT_FCALL                                               'strtotime'
         32        SEND_VAL                                                 '%2B1+month'
         33        INIT_FCALL                                               'strtotime'
         34        SEND_VAR                                                 !2
         35        DO_ICALL                                         $17     
         36        SEND_VAR                                                 $17
         37        DO_ICALL                                         $18     
         38        SEND_VAR                                                 $18
         39        DO_ICALL                                         $19     
         40        ASSIGN                                                   !3, $19
   10    41        INIT_ARRAY                                       ~21     !2, 'start_date'
   11    42        ADD_ARRAY_ELEMENT                                ~21     !3, 'end_date'
         43      > RETURN                                                   ~21
   13    44*     > RETURN                                                   null

End of function gettimerange

Function gettimerange2:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 21
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Z68l9
function name:  getTimeRange2
number of ops:  48
compiled vars:  !0 = $month, !1 = $year, !2 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      0
   16     2        INIT_FCALL                                               'str_pad'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 2
          5        SEND_VAL                                                 '0'
          6        SEND_VAL                                                 0
          7        DO_ICALL                                         $3      
          8        ASSIGN                                                   !0, $3
   17     9        JMP_SET                                          ~5      !1, ->26
         10        INIT_FCALL                                               'date'
         11        SEND_VAL                                                 'm'
         12        DO_ICALL                                         $6      
         13        IS_SMALLER                                               $6, !0
         14      > JMPZ                                                     ~7, ->21
         15    >   INIT_FCALL                                               'date'
         16        SEND_VAL                                                 'Y'
         17        DO_ICALL                                         $8      
         18        SUB                                              ~9      $8, 1
         19        QM_ASSIGN                                        ~10     ~9
         20      > JMP                                                      ->25
         21    >   INIT_FCALL                                               'date'
         22        SEND_VAL                                                 'Y'
         23        DO_ICALL                                         $11     
         24        QM_ASSIGN                                        ~10     $11
         25    >   QM_ASSIGN                                        ~5      ~10
         26        ASSIGN                                                   !1, ~5
   19    27        ROPE_INIT                                     4  ~14     !1
         28        ROPE_ADD                                      1  ~14     ~14, '-'
         29        ROPE_ADD                                      2  ~14     ~14, !0
         30        ROPE_END                                      3  ~13     ~14, '-01'
         31        INIT_ARRAY                                       ~16     ~13, 'start_date'
   20    32        INIT_FCALL                                               'date'
         33        SEND_VAL                                                 'Y-m-d'
         34        INIT_FCALL                                               'strtotime'
         35        SEND_VAL                                                 '%2B1+month'
         36        INIT_FCALL                                               'strtotime'
         37        FETCH_DIM_R                                      ~17     !2, 'start_date'
         38        SEND_VAL                                                 ~17
         39        DO_ICALL                                         $18     
         40        SEND_VAR                                                 $18
         41        DO_ICALL                                         $19     
         42        SEND_VAR                                                 $19
         43        DO_ICALL                                         $20     
         44        ADD_ARRAY_ELEMENT                                ~16     $20, 'end_date'
   18    45        ASSIGN                                                   !2, ~16
   22    46      > RETURN                                                   !2
   23    47*     > RETURN                                                   null

End of function gettimerange2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.96 ms | 1407 KiB | 23 Q