AdRock Posted October 17, 2013 Share Posted October 17, 2013 I have this function that creates breadcrumbs from the URL It appears to work but i get these error messages Notice: Undefined index: HTTPS in C:\www\mvc\libs\Braveheart.php on line 13Strict Standards: Only variables should be passed by reference in C:\www\mvc\libs\Braveheart.php on line 16 Line 13 points to $base_url = ($_SERVER['HTTPS'] ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/'; and line 16 is $last = end(array_keys($path)); Any ideas how i can remove these errors/warnings? here is the code public function breadcrumbs ($separator = ' » ', $home = 'Home') { $path = array_filter(explode('/', parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH))); $base_url = ($_SERVER['HTTPS'] ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/'; $breadcrumbs = array("<a href=\"$base_url\">$home</a>"); $last = end(array_keys($path)); foreach ($path AS $x => $crumb) { $title = ucwords(str_replace(array('.php', '_'), Array('', ' '), $crumb)); if ($x != $last){ $breadcrumbs[] = '<a href="'.$base_url.'/'.$crumb.'">'.$title.'</a>'; }else{ $breadcrumbs[] = $title; } } return implode($separator, $breadcrumbs); } Quote Link to comment Share on other sites More sharing options...
Solution Ch0cu3r Posted October 17, 2013 Solution Share Posted October 17, 2013 (edited) First notice message can be solved by checking to see if the HTTPS server exists $base_url = (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/'; Second error can solved with $keys = array_keys($path); $last = end($keys); // OR just $last = count($path) - 1; Edited October 17, 2013 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
AdRock Posted October 17, 2013 Author Share Posted October 17, 2013 Thanks Ch0cu3r Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.