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($format, time()); $next = date($format, strtotime('next '.$day_name)); $last = date($format, strtotime('last '.$day_name)); if($today_name == $day_name) { return date($format, time()); } else if(abs(time()-strtotime('next '.$day_name)) < abs(time()-strtotime('last '.$day_name))) { return date($format, strtotime('next '.$day_name)); } else { return 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('Sunday', 'past');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DZZDC
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   49     0  E >   INIT_FCALL                                               'rs_get_date_with_dayname_position_format'
          1        SEND_VAL                                                 'Sunday'
          2        SEND_VAL                                                 'past'
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
          5      > 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 = 50
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 50
2 jumps found. (Code = 43) Position 1 = 72, Position 2 = 82
Branch analysis from position: 72
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 82
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DZZDC
function name:  RS_GET_DATE_WITH_DAYNAME_POSITION_FORMAT
number of ops:  111
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_VAR                                                 !2
         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                                                 !5, !0
         41      > JMPZ                                                     ~25, ->50
   12    42    >   INIT_FCALL                                               'date'
         43        SEND_VAR                                                 !2
         44        INIT_FCALL                                               'time'
         45        DO_ICALL                                         $26     
         46        SEND_VAR                                                 $26
         47        DO_ICALL                                         $27     
         48      > RETURN                                                   $27
         49*       JMP                                                      ->91
   14    50    >   INIT_FCALL                                               'abs'
         51        INIT_FCALL                                               'time'
         52        DO_ICALL                                         $28     
         53        INIT_FCALL                                               'strtotime'
         54        CONCAT                                           ~29     'next+', !0
         55        SEND_VAL                                                 ~29
         56        DO_ICALL                                         $30     
         57        SUB                                              ~31     $28, $30
         58        SEND_VAL                                                 ~31
         59        DO_ICALL                                         $32     
         60        INIT_FCALL                                               'abs'
         61        INIT_FCALL                                               'time'
         62        DO_ICALL                                         $33     
         63        INIT_FCALL                                               'strtotime'
         64        CONCAT                                           ~34     'last+', !0
         65        SEND_VAL                                                 ~34
         66        DO_ICALL                                         $35     
         67        SUB                                              ~36     $33, $35
         68        SEND_VAL                                                 ~36
         69        DO_ICALL                                         $37     
         70        IS_SMALLER                                               $32, $37
         71      > JMPZ                                                     ~38, ->82
   16    72    >   INIT_FCALL                                               'date'
         73        SEND_VAR                                                 !2
         74        INIT_FCALL                                               'strtotime'
         75        CONCAT                                           ~39     'next+', !0
         76        SEND_VAL                                                 ~39
         77        DO_ICALL                                         $40     
         78        SEND_VAR                                                 $40
         79        DO_ICALL                                         $41     
         80      > RETURN                                                   $41
         81*       JMP                                                      ->91
   20    82    >   INIT_FCALL                                               'date'
         83        SEND_VAR                                                 !2
         84        INIT_FCALL                                               'strtotime'
         85        CONCAT                                           ~42     'last+', !0
         86        SEND_VAL                                                 ~42
         87        DO_ICALL                                         $43     
         88        SEND_VAR                                                 $43
         89        DO_ICALL                                         $44     
         90      > RETURN                                                   $44
   23    91*       IS_EQUAL                                                 !1, 'future'
         92*       JMPZ                                                     ~45, ->102
   25    93*       IS_NOT_EQUAL                                             !5, !0
         94*       JMPZ                                                     ~46, ->97
   27    95*       RETURN                                                   !7
         96*       JMP                                                      ->101
   31    97*       JMPZ                                                     !3, ->100
         98*       RETURN                                                   !7
         99*       JMP                                                      ->101
   32   100*       RETURN                                                   !6
        101*       JMP                                                      ->110
   37   102*       IS_NOT_EQUAL                                             !5, !0
        103*       JMPZ                                                     ~47, ->106
   39   104*       RETURN                                                   !8
        105*       JMP                                                      ->110
   43   106*       JMPZ                                                     !3, ->109
        107*       RETURN                                                   !6
        108*       JMP                                                      ->110
   44   109*       RETURN                                                   !8
   47   110*     > RETURN                                                   null

End of function rs_get_date_with_dayname_position_format

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.67 ms | 1407 KiB | 24 Q