3v4l.org

run code in 300+ PHP versions simultaneously
<?php $date = date("Y-m-d"); //w:星期几,0-6 //取得指定时间所属月的第一天 $firstday = date("Y-m-01",strtotime($date)); //取得指定时间所属月的最后一天 $lastday = date("Y-m-d",strtotime("$firstday +1 month -1 day")); //取得指定时间所属月的第一天是星期几 $w = date("w",strtotime($firstday)); //需要往前多取的天数(根据画面显示需要得出) $days_up = $w; //取得指定时间所属月的最后一天是星期几 $w = date("w",strtotime($lastday)); //需要往后多取的天数(根据画面显示需要得出) $days_down = 6 - $w; $start_date = date("Y-m-d",strtotime($firstday) - 86400 * $days_up); $end_date = date("Y-m-d",strtotime($lastday) + 86400 * $days_down); $days = (int) ((strtotime($end_date) - strtotime($start_date))/86400); $info = array( 'start_date'=>$start_date, 'end_date'=>$end_date, 'days'=>$days ); print_r($info);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4utAB
function name:  (null)
number of ops:  79
compiled vars:  !0 = $date, !1 = $firstday, !2 = $lastday, !3 = $w, !4 = $days_up, !5 = $days_down, !6 = $start_date, !7 = $end_date, !8 = $days, !9 = $info
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'date'
          1        SEND_VAL                                                 'Y-m-d'
          2        DO_ICALL                                         $10     
          3        ASSIGN                                                   !0, $10
    7     4        INIT_FCALL                                               'date'
          5        SEND_VAL                                                 'Y-m-01'
          6        INIT_FCALL                                               'strtotime'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $12     
          9        SEND_VAR                                                 $12
         10        DO_ICALL                                         $13     
         11        ASSIGN                                                   !1, $13
    9    12        INIT_FCALL                                               'date'
         13        SEND_VAL                                                 'Y-m-d'
         14        INIT_FCALL                                               'strtotime'
         15        NOP                                                      
         16        FAST_CONCAT                                      ~15     !1, '+%2B1+month+-1+day'
         17        SEND_VAL                                                 ~15
         18        DO_ICALL                                         $16     
         19        SEND_VAR                                                 $16
         20        DO_ICALL                                         $17     
         21        ASSIGN                                                   !2, $17
   12    22        INIT_FCALL                                               'date'
         23        SEND_VAL                                                 'w'
         24        INIT_FCALL                                               'strtotime'
         25        SEND_VAR                                                 !1
         26        DO_ICALL                                         $19     
         27        SEND_VAR                                                 $19
         28        DO_ICALL                                         $20     
         29        ASSIGN                                                   !3, $20
   14    30        ASSIGN                                                   !4, !3
   17    31        INIT_FCALL                                               'date'
         32        SEND_VAL                                                 'w'
         33        INIT_FCALL                                               'strtotime'
         34        SEND_VAR                                                 !2
         35        DO_ICALL                                         $23     
         36        SEND_VAR                                                 $23
         37        DO_ICALL                                         $24     
         38        ASSIGN                                                   !3, $24
   19    39        SUB                                              ~26     6, !3
         40        ASSIGN                                                   !5, ~26
   21    41        INIT_FCALL                                               'date'
         42        SEND_VAL                                                 'Y-m-d'
         43        INIT_FCALL                                               'strtotime'
         44        SEND_VAR                                                 !1
         45        DO_ICALL                                         $28     
         46        MUL                                              ~29     !4, 86400
         47        SUB                                              ~30     $28, ~29
         48        SEND_VAL                                                 ~30
         49        DO_ICALL                                         $31     
         50        ASSIGN                                                   !6, $31
   22    51        INIT_FCALL                                               'date'
         52        SEND_VAL                                                 'Y-m-d'
         53        INIT_FCALL                                               'strtotime'
         54        SEND_VAR                                                 !2
         55        DO_ICALL                                         $33     
         56        MUL                                              ~34     !5, 86400
         57        ADD                                              ~35     $33, ~34
         58        SEND_VAL                                                 ~35
         59        DO_ICALL                                         $36     
         60        ASSIGN                                                   !7, $36
   23    61        INIT_FCALL                                               'strtotime'
         62        SEND_VAR                                                 !7
         63        DO_ICALL                                         $38     
         64        INIT_FCALL                                               'strtotime'
         65        SEND_VAR                                                 !6
         66        DO_ICALL                                         $39     
         67        SUB                                              ~40     $38, $39
         68        DIV                                              ~41     ~40, 86400
         69        CAST                                          4  ~42     ~41
         70        ASSIGN                                                   !8, ~42
   25    71        INIT_ARRAY                                       ~44     !6, 'start_date'
   26    72        ADD_ARRAY_ELEMENT                                ~44     !7, 'end_date'
   27    73        ADD_ARRAY_ELEMENT                                ~44     !8, 'days'
   24    74        ASSIGN                                                   !9, ~44
   30    75        INIT_FCALL                                               'print_r'
         76        SEND_VAR                                                 !9
         77        DO_ICALL                                                 
         78      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.09 ms | 1400 KiB | 19 Q