我正在尝试使用Request::factory()
方法在 Kohana 的视图文件中回显一个请求,并且我在该请求中发送一个我无法在User
控制器中获取的值,这是我的代码:
视图文件:
<h1> Welcome to My First View File </h1>
<?php echo Request::factory("user",array("id" => 123))->execute(); ?>
然后User.php
控制器有这个代码:
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_User extends Controller {
public function action_index()
{
$value = $this->request->param('id');
$content = View::factory('menu')->bind("id", $value);
$this->response->body($content);
}
} // End User
并且视图menu.php
具有以下代码:
<h2> This is the view called by Request and Parameters send was:
<?php echo $id; ?>
</h2>
当我运行代码时它显示文本This is the view called by Request and Parameters send was:
但它不显示$id
任何人都可以告诉我为什么?
PS:对不起我的英语不好,因为它不是我的母语