3v4l.org

run code in 300+ PHP versions simultaneously
<?php function RS_GET_DATE_WITH_DAYNAME_POSITION_FORMAT($day_name, $position = 'future', $today_is_past = true, $format = 'Y-m-d H:i:s') { //$day = ucfirst($day_name); $today_name = date('l'); $today = date('Y-m-d 00:00:00'); // Je force l'heure à minuit sinon dans certain cas nous sommes déjà dans le future alors qu'on est aujourd'hui $next = date($format, strtotime('next '.$day_name)); $last = date($format, strtotime('last '.$day_name)); if($position == 'future') { if($today_name != $day_name) { return $next; } else { if($today_is_past) return $next; else return $today; } } else { if($today_name != $day_name) { return $last; } else { if($today_is_past) return $today; else return $last; } } } echo date('Y-m-d 00:00:00'); //echo RS_GET_DATE_WITH_DAYNAME_POSITION_FORMAT('Wednesday', 'future', true);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hr02V
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   INIT_FCALL                                               'date'
          1        SEND_VAL                                                 'Y-m-d+00%3A00%3A00'
          2        DO_ICALL                                         $0      
          3        ECHO                                                     $0
   37     4      > RETURN                                                   1

Function rs_get_date_with_dayname_position_format:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 41
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 36
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 39
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 45
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 48
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hr02V
function name:  RS_GET_DATE_WITH_DAYNAME_POSITION_FORMAT
number of ops:  50
compiled vars:  !0 = $day_name, !1 = $position, !2 = $today_is_past, !3 = $format, !4 = $today_name, !5 = $today, !6 = $next, !7 = $last
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      'future'
          2        RECV_INIT                                        !2      <true>
          3        RECV_INIT                                        !3      'Y-m-d+H%3Ai%3As'
    5     4        INIT_FCALL                                               'date'
          5        SEND_VAL                                                 'l'
          6        DO_ICALL                                         $8      
          7        ASSIGN                                                   !4, $8
    6     8        INIT_FCALL                                               'date'
          9        SEND_VAL                                                 'Y-m-d+00%3A00%3A00'
         10        DO_ICALL                                         $10     
         11        ASSIGN                                                   !5, $10
    7    12        INIT_FCALL                                               'date'
         13        SEND_VAR                                                 !3
         14        INIT_FCALL                                               'strtotime'
         15        CONCAT                                           ~12     'next+', !0
         16        SEND_VAL                                                 ~12
         17        DO_ICALL                                         $13     
         18        SEND_VAR                                                 $13
         19        DO_ICALL                                         $14     
         20        ASSIGN                                                   !6, $14
    8    21        INIT_FCALL                                               'date'
         22        SEND_VAR                                                 !3
         23        INIT_FCALL                                               'strtotime'
         24        CONCAT                                           ~16     'last+', !0
         25        SEND_VAL                                                 ~16
         26        DO_ICALL                                         $17     
         27        SEND_VAR                                                 $17
         28        DO_ICALL                                         $18     
         29        ASSIGN                                                   !7, $18
   10    30        IS_EQUAL                                                 !1, 'future'
         31      > JMPZ                                                     ~20, ->41
   12    32    >   IS_NOT_EQUAL                                             !4, !0
         33      > JMPZ                                                     ~21, ->36
   14    34    > > RETURN                                                   !6
         35*       JMP                                                      ->40
   18    36    > > JMPZ                                                     !2, ->39
         37    > > RETURN                                                   !6
         38*       JMP                                                      ->40
   19    39    > > RETURN                                                   !5
         40*       JMP                                                      ->49
   24    41    >   IS_NOT_EQUAL                                             !4, !0
         42      > JMPZ                                                     ~22, ->45
   26    43    > > RETURN                                                   !7
         44*       JMP                                                      ->49
   30    45    > > JMPZ                                                     !2, ->48
         46    > > RETURN                                                   !5
         47*       JMP                                                      ->49
   31    48    > > RETURN                                                   !7
   34    49*     > RETURN                                                   null

End of function rs_get_date_with_dayname_position_format

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.19 ms | 1400 KiB | 17 Q