3v4l.org

run code in 300+ PHP versions simultaneously
<?php // -------- PHP STORE HOURS --------- // ---------- Version 1.1 ----------- // -------- BY CORY ETZKORN --------- // -------- coryetzkorn.com --------- // -------- EDIT FOLLOWING SECTION ONLY --------- // Set your timezone (codes listed at http://php.net/manual/en/timezones.php) // Delete the following line if you've already defined a timezone elsewhere. date_default_timezone_set('Europe/Stockholm'); // Define daily open hours. Must be in 24-hour format, separated by dash. $time_range_mon = '11:00-20:30'; $time_range_tue = '11:00-20:30'; $time_range_wed = '11:00-20:30'; $time_range_thu = '11:00-20:30'; $time_range_fri = '11:00-21:30'; $time_range_sat = '11:00-21:30'; $time_range_sun = '12:00-19:30'; $time_range_christmas = '12:00-14:30'; $time_range_newyears = '12:00-14:30'; // OPTIONAL: Output current day's open hours $echo_daily_hours = false; // Switch to FALSE to hide numerical display of current hours $time_output = 'g a'; // Enter custom time output format (options listed here: http://php.net/manual/en/function.date.php) $time_separator = ' - '; // Choose how to indicate range (i.e XX - XX, XX to XX, XX until XX) // -------- END EDITING -------- // Gets current day of week $status_today = date("D"); $todays_date = date("d M"); if ($todays_date == "25 Dec"){ $status_today = "Christmas"; } if ($todays_date == "1 Jan"){ $status_today = "NewYears"; } // Gets current time of day in 00:00 format $current_time = date("G:i"); // Makes current time of day computer-readable $current_time_x = strtotime($current_time); // Builds an array, assigning user-defined time ranges to each day of week $all_days = array("Mon" => $time_range_mon, "Tue" => $time_range_tue, "Wed" => $time_range_wed, "Thu" => $time_range_thu, "Fri" => $time_range_fri, "Sat" => $time_range_sat, "Sun" => $time_range_sun, "Christmas" => $time_range_christmas, "NewYears" => $time_range_newyears); foreach ($all_days as &$each_day) { $each_day = explode("-", $each_day); $each_day[0] = strtotime($each_day[0]); $each_day[1] = strtotime($each_day[1]); } // Defines array of possible days of week $week_days = array("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", "Christmas", "NewYears"); // Compares current day of week to possible days of week and determines open vs closed output based on current day and time. foreach ($week_days as &$each_week_day) { if ($status_today == $each_week_day) { echo ''; if (($all_days[$each_week_day][0] <= $current_time_x) && ($all_days[$each_week_day][1] >= $current_time_x)) { } else { header( 'Location: http://www.bristolhotel.com/pizzeria/offlinepizza.php' ) ; } } } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 26
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 29
Branch analysis from position: 28
2 jumps found. (Code = 125) Position 1 = 48, Position 2 = 67
Branch analysis from position: 48
2 jumps found. (Code = 126) Position 1 = 49, Position 2 = 67
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
Branch analysis from position: 67
2 jumps found. (Code = 125) Position 1 = 70, Position 2 = 88
Branch analysis from position: 70
2 jumps found. (Code = 126) Position 1 = 71, Position 2 = 88
Branch analysis from position: 71
2 jumps found. (Code = 43) Position 1 = 73, Position 2 = 87
Branch analysis from position: 73
2 jumps found. (Code = 46) Position 1 = 78, Position 2 = 82
Branch analysis from position: 78
2 jumps found. (Code = 43) Position 1 = 83, Position 2 = 84
Branch analysis from position: 83
1 jumps found. (Code = 42) Position 1 = 87
Branch analysis from position: 87
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
Branch analysis from position: 84
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
Branch analysis from position: 82
Branch analysis from position: 87
Branch analysis from position: 88
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 88
Branch analysis from position: 67
Branch analysis from position: 29
Branch analysis from position: 26
filename:       /in/STg7h
function name:  (null)
number of ops:  90
compiled vars:  !0 = $time_range_mon, !1 = $time_range_tue, !2 = $time_range_wed, !3 = $time_range_thu, !4 = $time_range_fri, !5 = $time_range_sat, !6 = $time_range_sun, !7 = $time_range_christmas, !8 = $time_range_newyears, !9 = $echo_daily_hours, !10 = $time_output, !11 = $time_separator, !12 = $status_today, !13 = $todays_date, !14 = $current_time, !15 = $current_time_x, !16 = $all_days, !17 = $each_day, !18 = $week_days, !19 = $each_week_day
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                               'date_default_timezone_set'
          1        SEND_VAL                                                 'Europe%2FStockholm'
          2        DO_ICALL                                                 
   16     3        ASSIGN                                                   !0, '11%3A00-20%3A30'
   17     4        ASSIGN                                                   !1, '11%3A00-20%3A30'
   18     5        ASSIGN                                                   !2, '11%3A00-20%3A30'
   19     6        ASSIGN                                                   !3, '11%3A00-20%3A30'
   20     7        ASSIGN                                                   !4, '11%3A00-21%3A30'
   21     8        ASSIGN                                                   !5, '11%3A00-21%3A30'
   22     9        ASSIGN                                                   !6, '12%3A00-19%3A30'
   23    10        ASSIGN                                                   !7, '12%3A00-14%3A30'
   24    11        ASSIGN                                                   !8, '12%3A00-14%3A30'
   28    12        ASSIGN                                                   !9, <false>
   29    13        ASSIGN                                                   !10, 'g+a'
   30    14        ASSIGN                                                   !11, '+-+'
   35    15        INIT_FCALL                                               'date'
         16        SEND_VAL                                                 'D'
         17        DO_ICALL                                         $33     
         18        ASSIGN                                                   !12, $33
   37    19        INIT_FCALL                                               'date'
         20        SEND_VAL                                                 'd+M'
         21        DO_ICALL                                         $35     
         22        ASSIGN                                                   !13, $35
   38    23        IS_EQUAL                                                 !13, '25+Dec'
         24      > JMPZ                                                     ~37, ->26
   39    25    >   ASSIGN                                                   !12, 'Christmas'
   41    26    >   IS_EQUAL                                                 !13, '1+Jan'
         27      > JMPZ                                                     ~39, ->29
   42    28    >   ASSIGN                                                   !12, 'NewYears'
   48    29    >   INIT_FCALL                                               'date'
         30        SEND_VAL                                                 'G%3Ai'
         31        DO_ICALL                                         $41     
         32        ASSIGN                                                   !14, $41
   50    33        INIT_FCALL                                               'strtotime'
         34        SEND_VAR                                                 !14
         35        DO_ICALL                                         $43     
         36        ASSIGN                                                   !15, $43
   53    37        INIT_ARRAY                                       ~45     !0, 'Mon'
         38        ADD_ARRAY_ELEMENT                                ~45     !1, 'Tue'
         39        ADD_ARRAY_ELEMENT                                ~45     !2, 'Wed'
         40        ADD_ARRAY_ELEMENT                                ~45     !3, 'Thu'
         41        ADD_ARRAY_ELEMENT                                ~45     !4, 'Fri'
         42        ADD_ARRAY_ELEMENT                                ~45     !5, 'Sat'
         43        ADD_ARRAY_ELEMENT                                ~45     !6, 'Sun'
         44        ADD_ARRAY_ELEMENT                                ~45     !7, 'Christmas'
         45        ADD_ARRAY_ELEMENT                                ~45     !8, 'NewYears'
         46        ASSIGN                                                   !16, ~45
   54    47      > FE_RESET_RW                                      $47     !16, ->67
         48    > > FE_FETCH_RW                                              $47, !17, ->67
   55    49    >   INIT_FCALL                                               'explode'
         50        SEND_VAL                                                 '-'
         51        SEND_VAR                                                 !17
         52        DO_ICALL                                         $48     
         53        ASSIGN                                                   !17, $48
   56    54        INIT_FCALL                                               'strtotime'
         55        FETCH_DIM_R                                      ~51     !17, 0
         56        SEND_VAL                                                 ~51
         57        DO_ICALL                                         $52     
         58        ASSIGN_DIM                                               !17, 0
         59        OP_DATA                                                  $52
   57    60        INIT_FCALL                                               'strtotime'
         61        FETCH_DIM_R                                      ~54     !17, 1
         62        SEND_VAL                                                 ~54
         63        DO_ICALL                                         $55     
         64        ASSIGN_DIM                                               !17, 1
         65        OP_DATA                                                  $55
   54    66      > JMP                                                      ->48
         67    >   FE_FREE                                                  $47
   61    68        ASSIGN                                                   !18, <array>
   64    69      > FE_RESET_RW                                      $57     !18, ->88
         70    > > FE_FETCH_RW                                              $57, !19, ->88
   65    71    >   IS_EQUAL                                                 !12, !19
         72      > JMPZ                                                     ~58, ->87
   66    73    >   ECHO                                                     ''
   67    74        FETCH_DIM_R                                      ~59     !16, !19
         75        FETCH_DIM_R                                      ~60     ~59, 0
         76        IS_SMALLER_OR_EQUAL                              ~61     ~60, !15
         77      > JMPZ_EX                                          ~61     ~61, ->82
         78    >   FETCH_DIM_R                                      ~62     !16, !19
         79        FETCH_DIM_R                                      ~63     ~62, 1
         80        IS_SMALLER_OR_EQUAL                              ~64     !15, ~63
         81        BOOL                                             ~61     ~64
         82    > > JMPZ                                                     ~61, ->84
         83    > > JMP                                                      ->87
   69    84    >   INIT_FCALL                                               'header'
         85        SEND_VAL                                                 'Location%3A+http%3A%2F%2Fwww.bristolhotel.com%2Fpizzeria%2Fofflinepizza.php'
         86        DO_ICALL                                                 
   64    87    > > JMP                                                      ->70
         88    >   FE_FREE                                                  $57
   74    89      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.62 ms | 1404 KiB | 23 Q