Fuelphpのプレゼンタ(ビューモデル)⇨モデルのやりとりがうまくいかずエラーが発生します。
app/classes/controller/test.php <?php use \Model\Test; class Controller_Test extends Controller { public function action_index() { return Response::forge(Presenter::forge('test/index')); } }
app/classes/controller/test.php <?php class Model_Test extends Model { public static function get_index() { $result= 1; return $result; } }
app/classes/presenter/test/index.php <?php class Presenter_Testhome_food extends Presenter { public function view() { $this->title = 'クラス'; $foodsObj = Model_Test::get_index(); $this->id = $foodsObj; } }
app/views/test/index.php <html> <head> <meta charset="UTF-8" /> <title><?php echo $title; ?> </title> </head> <body> <table border = 1> <thead> <tr> <th>id</th> </tr> <tr> <th><?php echo $id; ?></th> </tr> </thead> </table> </body> </html>
この時 syntax error, unexpected '$this' (T_VARIABLE)
というエラーが発生します。
$thisを読み取れないということですが、画面上を見るとthis->titleの箇所は正常に動いていて問題はthis->idの箇所というところまではつかめています。ただそれ以降がわかりません。
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/11/30 21:13