Ich studiere Kohana 3.3 mit sehr einfachen und einfachen Beispielen aus dem Internet.Kohana 3.3 Ansicht foreach keine Ausgabe Array
Mein Controller:
Klasse Controller_Index erweitert Controller_Template {
public $template='v_index';
public function action_index()
{
$this->template->title='Online store';
$this->template->content='Homepage';
}
public function action_catalog()
{
$title='Products catalog';
$products = array(
'Product 1'=>100,
'Product 2'=>200,
);
$this->template->title='Online products store';
$this->template->content=View::factory('v_catalog')
->bind('products',$products)
->bind('product',$product)
->bind('cost',$cost)
->bind('title',$title);
}
}
Meine Ansicht v_index.php
<h1><?=$title;?></h1>
<hr>
<p><?=$content;?></p>
Meine Ansicht v_catalog.php:
<h2><?=$title?></h2>
<? foreach ($products as $product=>$cost): ?>
<p><?=$product?><strong><?=$cost?></strong></p>
<? endforeach; ?>
Wenn ich gehe zu http://localhost/kohana/index/catalog Browser gibt zwei Titel aus: Online-Shop und Produktkatalog in Ordnung. Aber an der Stelle, an der sich der foreach-Kreis befindet, gibt es
$cost): ?>
Was mache ich falsch? Kann ich dieses Array nicht durchlaufen? Oder ist meine Syntax falsch? Wäre für Hilfe mit meinem Fehler dankbar.