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_name = ucfirst($day_name); // Pour être sûr que le premier caractère soit en majuscule $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 RS_GET_DATE_WITH_DAYNAME_POSITION_FORMAT('Wednesday', 'future', false);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g46WJ
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                                                 <false>
          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 = 36, Position 2 = 45
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 40
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 43
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
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 = 47, Position 2 = 49
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 49
2 jumps found. (Code = 43) Position 1 = 50, Position 2 = 52
Branch analysis from position: 50
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g46WJ
function name:  RS_GET_DATE_WITH_DAYNAME_POSITION_FORMAT
number of ops:  54
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'
    4     4        INIT_FCALL                                               'ucfirst'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $8      
          7        ASSIGN                                                   !0, $8
    5     8        INIT_FCALL                                               'date'
          9        SEND_VAL                                                 'l'
         10        DO_ICALL                                         $10     
         11        ASSIGN                                                   !4, $10
    6    12        INIT_FCALL                                               'date'
         13        SEND_VAL                                                 'Y-m-d+00%3A00%3A00'
         14        DO_ICALL                                         $12     
         15        ASSIGN                                                   !5, $12
    7    16        INIT_FCALL                                               'date'
         17        SEND_VAR                                                 !3
         18        INIT_FCALL                                               'strtotime'
         19        CONCAT                                           ~14     'next+', !0
         20        SEND_VAL                                                 ~14
         21        DO_ICALL                                         $15     
         22        SEND_VAR                                                 $15
         23        DO_ICALL                                         $16     
         24        ASSIGN                                                   !6, $16
    8    25        INIT_FCALL                                               'date'
         26        SEND_VAR                                                 !3
         27        INIT_FCALL                                               'strtotime'
         28        CONCAT                                           ~18     'last+', !0
         29        SEND_VAL                                                 ~18
         30        DO_ICALL                                         $19     
         31        SEND_VAR                                                 $19
         32        DO_ICALL                                         $20     
         33        ASSIGN                                                   !7, $20
   10    34        IS_EQUAL                                                 !1, 'future'
         35      > JMPZ                                                     ~22, ->45
   12    36    >   IS_NOT_EQUAL                                             !4, !0
         37      > JMPZ                                                     ~23, ->40
   14    38    > > RETURN                                                   !6
         39*       JMP                                                      ->44
   18    40    > > JMPZ                                                     !2, ->43
         41    > > RETURN                                                   !6
         42*       JMP                                                      ->44
   19    43    > > RETURN                                                   !5
         44*       JMP                                                      ->53
   24    45    >   IS_NOT_EQUAL                                             !4, !0
         46      > JMPZ                                                     ~24, ->49
   26    47    > > RETURN                                                   !7
         48*       JMP                                                      ->53
   30    49    > > JMPZ                                                     !2, ->52
         50    > > RETURN                                                   !5
         51*       JMP                                                      ->53
   31    52    > > RETURN                                                   !7
   34    53*     > RETURN                                                   null

End of function rs_get_date_with_dayname_position_format

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.07 ms | 1403 KiB | 20 Q