1
I have the library next 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 Readcrumbs:
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 exhibition:
<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 run is appearing the following message:
PHP Error was encountered
Severity: Runtime Notice
Message: Only variables should be passed by Ference
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 moderador Painel_controle.php Line: 13 Function: output
File: D: wamp www Portalcompras index.php Line: 315 Function: require_once
I couldn’t identify the mistake. Can someone help me?
Your tip fixed my problem. I did exactly as you indicated and the error message disappeared.
– Walder