3v4l.org

run code in 300+ PHP versions simultaneously
<?php function period_to_timestamps($period) { switch($period) { case "last_7_days": $start = strtotime('-7 days'); $end = strtotime('now'); break; case "this_month": $start = strtotime('first day of this month'); $end = strtotime('now'); break; case "last_month": $start = strtotime('first day of last month'); $end = strtotime('last day of last month'); break; case "this_year": $start = strtotime('01-01-' . date('Y', strtotime('now'))); $end = strtotime('now'); break; case "last_year": $start = strtotime('first day of last year'); $end = strtotime('last day of last year'); break; default: $start = strtotime('now'); $end = strtotime('now'); } return array($start, $end); } var_dump(period_to_timestamps('last_7_days'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AjPdW
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'period_to_timestamps'
          2        SEND_VAL                                                 'last_7_days'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
          6      > RETURN                                                   1

Function period_to_timestamps:
Finding entry points
Branch analysis from position: 0
7 jumps found. (Code = 188) Position 1 = 13, Position 2 = 22, Position 3 = 31, Position 4 = 40, Position 5 = 57, Position 6 = 66, Position 7 = 2
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 74
Branch analysis from position: 74
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 74
Branch analysis from position: 74
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 74
Branch analysis from position: 74
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 74
Branch analysis from position: 74
Branch analysis from position: 57
1 jumps found. (Code = 42) Position 1 = 74
Branch analysis from position: 74
Branch analysis from position: 66
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 6, Position 2 = 22
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 31
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 40
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 57
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 66
Branch analysis from position: 66
Branch analysis from position: 57
Branch analysis from position: 40
Branch analysis from position: 31
Branch analysis from position: 22
Branch analysis from position: 13
filename:       /in/AjPdW
function name:  period_to_timestamps
number of ops:  78
compiled vars:  !0 = $period, !1 = $start, !2 = $end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1      > SWITCH_STRING                                            !0, [ 'last_7_days':->13, 'this_month':->22, 'last_month':->31, 'this_year':->40, 'last_year':->57, ], ->66
    5     2    >   IS_EQUAL                                                 !0, 'last_7_days'
          3      > JMPNZ                                                    ~3, ->13
    9     4    >   IS_EQUAL                                                 !0, 'this_month'
          5      > JMPNZ                                                    ~3, ->22
   13     6    >   IS_EQUAL                                                 !0, 'last_month'
          7      > JMPNZ                                                    ~3, ->31
   17     8    >   IS_EQUAL                                                 !0, 'this_year'
          9      > JMPNZ                                                    ~3, ->40
   21    10    >   IS_EQUAL                                                 !0, 'last_year'
         11      > JMPNZ                                                    ~3, ->57
         12    > > JMP                                                      ->66
    6    13    >   INIT_FCALL                                               'strtotime'
         14        SEND_VAL                                                 '-7+days'
         15        DO_ICALL                                         $4      
         16        ASSIGN                                                   !1, $4
    7    17        INIT_FCALL                                               'strtotime'
         18        SEND_VAL                                                 'now'
         19        DO_ICALL                                         $6      
         20        ASSIGN                                                   !2, $6
    8    21      > JMP                                                      ->74
   10    22    >   INIT_FCALL                                               'strtotime'
         23        SEND_VAL                                                 'first+day+of+this+month'
         24        DO_ICALL                                         $8      
         25        ASSIGN                                                   !1, $8
   11    26        INIT_FCALL                                               'strtotime'
         27        SEND_VAL                                                 'now'
         28        DO_ICALL                                         $10     
         29        ASSIGN                                                   !2, $10
   12    30      > JMP                                                      ->74
   14    31    >   INIT_FCALL                                               'strtotime'
         32        SEND_VAL                                                 'first+day+of+last+month'
         33        DO_ICALL                                         $12     
         34        ASSIGN                                                   !1, $12
   15    35        INIT_FCALL                                               'strtotime'
         36        SEND_VAL                                                 'last+day+of+last+month'
         37        DO_ICALL                                         $14     
         38        ASSIGN                                                   !2, $14
   16    39      > JMP                                                      ->74
   18    40    >   INIT_FCALL                                               'strtotime'
         41        INIT_FCALL                                               'date'
         42        SEND_VAL                                                 'Y'
         43        INIT_FCALL                                               'strtotime'
         44        SEND_VAL                                                 'now'
         45        DO_ICALL                                         $16     
         46        SEND_VAR                                                 $16
         47        DO_ICALL                                         $17     
         48        CONCAT                                           ~18     '01-01-', $17
         49        SEND_VAL                                                 ~18
         50        DO_ICALL                                         $19     
         51        ASSIGN                                                   !1, $19
   19    52        INIT_FCALL                                               'strtotime'
         53        SEND_VAL                                                 'now'
         54        DO_ICALL                                         $21     
         55        ASSIGN                                                   !2, $21
   20    56      > JMP                                                      ->74
   22    57    >   INIT_FCALL                                               'strtotime'
         58        SEND_VAL                                                 'first+day+of+last+year'
         59        DO_ICALL                                         $23     
         60        ASSIGN                                                   !1, $23
   23    61        INIT_FCALL                                               'strtotime'
         62        SEND_VAL                                                 'last+day+of+last+year'
         63        DO_ICALL                                         $25     
         64        ASSIGN                                                   !2, $25
   24    65      > JMP                                                      ->74
   26    66    >   INIT_FCALL                                               'strtotime'
         67        SEND_VAL                                                 'now'
         68        DO_ICALL                                         $27     
         69        ASSIGN                                                   !1, $27
   27    70        INIT_FCALL                                               'strtotime'
         71        SEND_VAL                                                 'now'
         72        DO_ICALL                                         $29     
         73        ASSIGN                                                   !2, $29
   30    74    >   INIT_ARRAY                                       ~31     !1
         75        ADD_ARRAY_ELEMENT                                ~31     !2
         76      > RETURN                                                   ~31
   31    77*     > RETURN                                                   null

End of function period_to_timestamps

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.27 ms | 1407 KiB | 20 Q