My PHP files in my root directory INCLUDE header.php. Header.php INCLUDEs functions.php. I'm adding new pages in a subdirectory, so I added leading slashes to all my links in header.php: CSS, menu items and the subsequent INCLUDE to functions.php. The CSS and menu items work fine on this page in the subdirectory, but the functions don't work. There are no links in the functions that seem to need leading slashes.
Does the combination of include
and leading slashes require modifying functions?
From a page in the root directory:
include('header.php');
From a page in the subdirectory:
include('/header.php');
From header.php:
include('/functions.php');
And the function that no longer works (called from pages in the root directory or subdirectory):
function show_date($array_name){
if (date("Y F j",strtotime($array_name["exhibit_open"])) == date("Y F j",strtotime($array_name["exhibit_close"]))){
echo date("F j, Y",strtotime($array_name["exhibit_open"]));
}
elseif (date("Y",strtotime($array_name["exhibit_open"])) != date("Y",strtotime($array_name["exhibit_close"]))) {
$first_date_format = "F j, Y";
echo date($first_date_format,strtotime($array_name["exhibit_open"])). " - ". date("F j, Y",strtotime($array_name["exhibit_close"]));
} elseif (date("F",strtotime($array_name["exhibit_open"])) != date("F",strtotime($array_name["exhibit_close"]))){
$first_date_format = "F j";
echo date($first_date_format,strtotime($array_name["exhibit_open"])). " - ". date("F j, Y",strtotime($array_name["exhibit_close"]));
} else {
$first_date_format = "j";
echo date("F j",strtotime($array_name["exhibit_open"])). " - ". date($first_date_format,strtotime($array_name["exhibit_close"])). ", ". date("Y",strtotime($array_name["exhibit_close"]));
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…