简体   繁体   English

严格标准:只有变量才能通过动态面包屑通过引用传递

[英]Strict Standards: Only variables should be passed by reference with dynamic breadcrumb

right now I'm working on a site that has 3 main layouts, header, main layout and footer, they are all called by the same controller. 现在,我正在一个具有3个主要布局,页眉,主要布局和页脚的站点上工作,它们都由同一控制器调用。 The main layout change depending on the request. 主布局根据要求进行更改。 But header and footer will be always the same. 但是页眉和页脚将始终相同。 In my header there's a dyinamic breadcrumb that I got from Dominic Barnes in this post. 在我的标头中,有一个动态面包屑是我从Dominic Barnes获得的。

PHP Simple dynamic breadcrumb PHP简单动态面包屑

The problem is that I don't know if I put it on the correct place since I have 2 errors: 问题是我不知道是否将其放在正确的位置,因为有两个错误:

Notice: Undefined index: HTTPS Strict Standards: Only variables should be passed by reference in 注意:未定义索引:HTTPS严格标准:仅变量应通过引用传递给

I put the code from Dominic Barnes in my html like this: 我将Dominic Barnes的代码放在html中,如下所示:

<?php
function breadcrumbs($separator = ' &raquo; ', $home = 'Home') {

$path = array_filter(explode('/', parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)));


$base = ($_SERVER['HTTPS'] ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/';


$breadcrumbs = Array("<a href=\"$base\">$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$crumb\">$title</a>";
    else
        $breadcrumbs[] = $title;
}
return implode($separator, $breadcrumbs);
}

?>

<div class="breadcrumb-line breadcrumb-line-wide">
  <ul class="breadcrumb">
   <li class="active" >
    <p><i class="icon-home2 position-left"></i><?= breadcrumbs() ?></p>
   </li>
 </ul>
</div>

The code from Dominic, is supposed to be on my controller or on my view html? 来自Dominic的代码,应该在我的控制器上还是在我的html视图上?

Sorry if this is a noob question but I'm kinda new on all of this. 抱歉,这是一个菜鸟问题,但我在所有这些方面还是新手。

Possible your variable $_SERVER['HTTPS'] is undefined. 可能您的变量$_SERVER['HTTPS']未定义。

After line: 下一行:

$base = ($_SERVER['HTTPS'] ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/';

Insert: var_dump($_SERVER['HTTPS']) . 插入: var_dump($_SERVER['HTTPS']) And check the value. 并检查值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM