Answer the question
In order to leave comments, you need to log in
PHP include based on day of the week and time?
Hello!
I have a code on my site that displays content depending on the day of the week:
<? include($_SERVER['DOCUMENT_ROOT'].'/blocks/head.php');?>
<? if (date('l') == 'Sunday') {
include($_SERVER['DOCUMENT_ROOT'].'/blocks/header-sun.php');
} if (date('l') == 'Monday') {
include($_SERVER['DOCUMENT_ROOT'].'/blocks/header.php');
} if (date('l') == 'Tuesday') {
include($_SERVER['DOCUMENT_ROOT'].'/blocks/header.php');
} if (date('l') == 'Wednesday') {
include($_SERVER['DOCUMENT_ROOT'].'/blocks/header.php');
} if (date('l') == 'Thursday') {
include($_SERVER['DOCUMENT_ROOT'].'/blocks/header.php');
} if (date('l') == 'Friday') {
include($_SERVER['DOCUMENT_ROOT'].'/blocks/header-fri.php');
} if (date('l') == 'Saturday') {
include($_SERVER['DOCUMENT_ROOT'].'/blocks/header-sat.php');
}?>
Answer the question
In order to leave comments, you need to log in
Be sure to read about RFI and LFI vulnerabilities.
if (file_exists(DOCROOT . '/blocks/header-' . strtolower(date('l')) . '.php') {
inclide DOCROOT . '/blocks/header-' . strtolower(date('l')) . '.php';
} else {
inclide DOCROOT . '/blocks/header.php';
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question