連想配列に設定して定義
概要
コントローラーなどでビューにデータを渡す方法を定義
arrayにて作成された連想配列より設定
コントローラー定義
<?php
// サンプルコントローラー
class Controller_Sample01 extends Controller
{
// アクションを省略時のデフォルトの画面
public function action_index()
{
//ビューに渡す変数を格納する
$data = array();
// データを設定する
$data['username'] = 'ほげほげ';
$data['title'] = 'サンプルテスト(ビュー)';
// ビューに設定する
return View::forge('sample01/index', $data);
}
}
ビューファイル定義
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title><?= $title ?></title>
</head>
<body>
ようこそ, <?= $username ?>さん.
</body>
</html>
最終更新:2013年05月23日 00:13