我正在学习Kohana 3.3使用来自Internet的非常简单和基本的示例。Kohana 3.3查看foreach不输出数组
我的控制器:
类Controller_Index延伸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);
}
}
我的观点v_index.php
<h1><?=$title;?></h1>
<hr>
<p><?=$content;?></p>
我的观点v_catalog.php:
<h2><?=$title?></h2>
<? foreach ($products as $product=>$cost): ?>
<p><?=$product?><strong><?=$cost?></strong></p>
<? endforeach; ?>
当我去http://localhost/kohana/index/catalog浏览器输出两个标题:在线商店和产品目录确定。但在foreach圈所在的位置输出
$cost): ?>
我在做什么错?我无法循环访问这个数组吗?或者,也许我的语法错了?将不胜感激,以帮助我的错误。