I have the following library in codeigniter:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Breadcrumb {
private $breadcrumbs = array();
private $separator = ' > ';
private $start = '<div id="breadcrumb">';
private $end = '</div>';
public function __construct($params = array()){
if (count($params) > 0){
$this->initialize($params);
}
}
private function initialize($params = array()){
if (count($params) > 0){
foreach ($params as $key => $val){
if (isset($this->{'_' . $key})){
$this->{'_' . $key} = $val;
}
}
}
}
function add($title, $href){
if (!$title OR !$href) return;
$this->breadcrumbs[] = array('title' => $title, 'href' => $href);
}
function output(){
if ($this->breadcrumbs) {
$output = $this->start;
foreach ($this->breadcrumbs as $key => $crumb) {
if ($key){
$output .= $this->separator;
}
if (end(array_keys($this->breadcrumbs)) == $key) {
$output .= '<span>' . $crumb['title'] . '</span>';
}
else {
$output .= '<a href="' . $crumb['href'] . '">' . $crumb['title'] . '</a>';
}
}
return $output . $this->end . PHP_EOL;
}
return '';
}
}
In the controller I insert the breadcrumbs:
public function index(){
$this->breadcrumb->add('Home', base_url());
$this->breadcrumb->add('Tutorials', base_url().'tutorials');
$this->breadcrumb->add('Spring Tutorial', base_url().'tutorials/spring-tutorials');
$this->dados['breadcrumb'] = $this->breadcrumb->output();
$this->dados['conteudo'] = 'layouts/moderador/painel_controle_view';
$this->load->view('layouts/layout_master',$this->dados);
}
And in the view I make the display:
<div id="conteudo" class="container principal">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="panel panel-default">
<div class="panel-body">
<p>PAINEL DE CONTROLE</p>
<p><?= (!empty($breadcrumb)?$breadcrumb:''); ?></p>
</div>
</div>
</div>
</div>
When I run the following message appears:
A PHP Error was encountered
Severity: Runtime Notice
Message: Only variables should be passed by reference
Filename: libraries / Breadcrumb.php
Line Number: 37
Backtrace:
File: D: \ wamp \ www \ PortalCompras \ application \ libraries \ Breadcrumb.php Line: 37 Function: _error_handler
File: D: \ wamp \ www \ PortalCompras \ application \ controllers \ moderator \ ControlPaint.php Line: 13 Function: output
File: D: \ wamp \ www \ PortalCompras \ index.php Line: 315 Function: require_once
I could not identify the error. Can anyone help me?