3v4l.org

run code in 300+ PHP versions simultaneously
<?php $date = (new \DateTime('27-05-2018')); if (($weekDay = $date->format('N')) < 4) { // If the date is already a Monday, return it as-is $date->modify('next thursday'); } elseif ($weekDay > 4) { // Otherwise, return the date of the nearest Monday in the past // This includes Sunday in the previous week instead of it being the start of a new week $date->modify('last thursday'); } var_dump($weekDay); var_dump($date);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 14
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 19
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/8cIVv
function name:  (null)
number of ops:  26
compiled vars:  !0 = $date, !1 = $weekDay
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   NEW                                              $2      'DateTime'
          1        SEND_VAL_EX                                              '27-05-2018'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
    7     4        INIT_METHOD_CALL                                         !0, 'format'
          5        SEND_VAL_EX                                              'N'
          6        DO_FCALL                                      0  $5      
          7        ASSIGN                                           ~6      !1, $5
          8        IS_SMALLER                                               ~6, 4
          9      > JMPZ                                                     ~7, ->14
    9    10    >   INIT_METHOD_CALL                                         !0, 'modify'
         11        SEND_VAL_EX                                              'next+thursday'
         12        DO_FCALL                                      0          
         13      > JMP                                                      ->19
   10    14    >   IS_SMALLER                                               4, !1
         15      > JMPZ                                                     ~9, ->19
   13    16    >   INIT_METHOD_CALL                                         !0, 'modify'
         17        SEND_VAL_EX                                              'last+thursday'
         18        DO_FCALL                                      0          
   15    19    >   INIT_FCALL                                               'var_dump'
         20        SEND_VAR                                                 !1
         21        DO_ICALL                                                 
   17    22        INIT_FCALL                                               'var_dump'
         23        SEND_VAR                                                 !0
         24        DO_ICALL                                                 
         25      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.1 ms | 1400 KiB | 15 Q