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' ) ; } } } ?>
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Output for 5.0.0 - 5.0.5
Fatal error: Call to undefined function date_default_timezone_set() in /in/STg7h on line 13
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in /in/STg7h on line 54
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected '&', expecting T_VARIABLE or '$' in /in/STg7h on line 54
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_VARIABLE' or `'$'' in /in/STg7h on line 54
Process exited with code 255.

preferences:
259.19 ms | 401 KiB | 399 Q