3v4l.org

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

End of function rs_get_date_with_dayname_position_format

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.08 ms | 1394 KiB | 22 Q