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', time()); $today = date('Y-m-d 00:00:00', time()); // 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('l', time()); //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/rfOAt
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   INIT_FCALL                                               'date'
          1        SEND_VAL                                                 'l'
          2        INIT_FCALL                                               'time'
          3        DO_ICALL                                         $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                         $1      
          6        ECHO                                                     $1
   37     7      > 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 = 38, Position 2 = 47
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 42
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
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
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 51
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 51
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 54
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 54
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rfOAt
function name:  RS_GET_DATE_WITH_DAYNAME_POSITION_FORMAT
number of ops:  56
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        INIT_FCALL                                               'time'
          7        DO_ICALL                                         $8      
          8        SEND_VAR                                                 $8
          9        DO_ICALL                                         $9      
         10        ASSIGN                                                   !4, $9
    6    11        INIT_FCALL                                               'date'
         12        SEND_VAL                                                 'Y-m-d+00%3A00%3A00'
         13        INIT_FCALL                                               'time'
         14        DO_ICALL                                         $11     
         15        SEND_VAR                                                 $11
         16        DO_ICALL                                         $12     
         17        ASSIGN                                                   !5, $12
    7    18        INIT_FCALL                                               'date'
         19        SEND_VAR                                                 !3
         20        INIT_FCALL                                               'strtotime'
         21        CONCAT                                           ~14     'next+', !0
         22        SEND_VAL                                                 ~14
         23        DO_ICALL                                         $15     
         24        SEND_VAR                                                 $15
         25        DO_ICALL                                         $16     
         26        ASSIGN                                                   !6, $16
    8    27        INIT_FCALL                                               'date'
         28        SEND_VAR                                                 !3
         29        INIT_FCALL                                               'strtotime'
         30        CONCAT                                           ~18     'last+', !0
         31        SEND_VAL                                                 ~18
         32        DO_ICALL                                         $19     
         33        SEND_VAR                                                 $19
         34        DO_ICALL                                         $20     
         35        ASSIGN                                                   !7, $20
   10    36        IS_EQUAL                                                 !1, 'future'
         37      > JMPZ                                                     ~22, ->47
   12    38    >   IS_NOT_EQUAL                                             !4, !0
         39      > JMPZ                                                     ~23, ->42
   14    40    > > RETURN                                                   !6
         41*       JMP                                                      ->46
   18    42    > > JMPZ                                                     !2, ->45
         43    > > RETURN                                                   !6
         44*       JMP                                                      ->46
   19    45    > > RETURN                                                   !5
         46*       JMP                                                      ->55
   24    47    >   IS_NOT_EQUAL                                             !4, !0
         48      > JMPZ                                                     ~24, ->51
   26    49    > > RETURN                                                   !7
         50*       JMP                                                      ->55
   30    51    > > JMPZ                                                     !2, ->54
         52    > > RETURN                                                   !5
         53*       JMP                                                      ->55
   31    54    > > RETURN                                                   !7
   34    55*     > RETURN                                                   null

End of function rs_get_date_with_dayname_position_format

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.2 ms | 1392 KiB | 19 Q