I have a breadcrumb script and its displaying an error:
"Notice: Undefined index: HTTPS in ... on line ..."
The code line is:
$base = ($_SERVER['HTTPS'] ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/';
How can I solve this?
I have a breadcrumb script and its displaying an error:
"Notice: Undefined index: HTTPS in ... on line ..."
The code line is:
$base = ($_SERVER['HTTPS'] ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/';
How can I solve this?
Check for the existence of the HTTPS
key first using isset
:
$base = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/';
In this particular case you only need to check existence so it would be safe to simplify it to:
$base = (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/';