3v4l.org

run code in 300+ PHP versions simultaneously
<?php function lastWeekDay ($mnt) { $result = strtotime("last day of $mnt"); $day = date('D', $result); if ('Sun' === $day) { $result -= 86400 * 2; } if ('Sat' === $day) { $result -= 86400; } return $result; } echo date('Y-m-d', mktime(0,0,0,date('n')-1,1,date('Y')));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RnXh2
function name:  (null)
number of ops:  21
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'date'
          1        SEND_VAL                                                 'Y-m-d'
          2        INIT_FCALL                                               'mktime'
          3        SEND_VAL                                                 0
          4        SEND_VAL                                                 0
          5        SEND_VAL                                                 0
          6        INIT_FCALL                                               'date'
          7        SEND_VAL                                                 'n'
          8        DO_ICALL                                         $0      
          9        SUB                                              ~1      $0, 1
         10        SEND_VAL                                                 ~1
         11        SEND_VAL                                                 1
         12        INIT_FCALL                                               'date'
         13        SEND_VAL                                                 'Y'
         14        DO_ICALL                                         $2      
         15        SEND_VAR                                                 $2
         16        DO_ICALL                                         $3      
         17        SEND_VAR                                                 $3
         18        DO_ICALL                                         $4      
         19        ECHO                                                     $4
         20      > RETURN                                                   1

Function lastweekday:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 18
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
Branch analysis from position: 15
filename:       /in/RnXh2
function name:  lastWeekDay
number of ops:  20
compiled vars:  !0 = $mnt, !1 = $result, !2 = $day
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'strtotime'
          2        NOP                                                      
          3        FAST_CONCAT                                      ~3      'last+day+of+', !0
          4        SEND_VAL                                                 ~3
          5        DO_ICALL                                         $4      
          6        ASSIGN                                                   !1, $4
    5     7        INIT_FCALL                                               'date'
          8        SEND_VAL                                                 'D'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $6      
         11        ASSIGN                                                   !2, $6
    6    12        IS_IDENTICAL                                             !2, 'Sun'
         13      > JMPZ                                                     ~8, ->15
    8    14    >   ASSIGN_OP                                     2          !1, 172800
   10    15    >   IS_IDENTICAL                                             !2, 'Sat'
         16      > JMPZ                                                     ~10, ->18
   12    17    >   ASSIGN_OP                                     2          !1, 86400
   14    18    > > RETURN                                                   !1
   15    19*     > RETURN                                                   null

End of function lastweekday

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.6 ms | 1400 KiB | 19 Q