私はPHPを学んでいます:懸念、MVC、関数、配列、作品の分離。私は間違いなく今は失われている。私は、既存の認証フレームワーク使用していますPHP MVC - 未定義の変数
:
https://github.com/panique/huge/
// app/core/View.php
/**
* Class View
* The part that handles all the output
*/
class View
{
/**
* simply includes (=shows) the view. this is done from the controller. In the controller, you usually say
* $this->view->render('help/index'); to show (in this example) the view index.php in the folder help.
* Usually the Class and the method are the same like the view, but sometimes you need to show different views.
* @param string $filename Path of the to-be-rendered view, usually folder/file(.php)
* @param array $data Data to be used in the view
*/
public function render($filename, $data = null)
{
if ($data) {
foreach ($data as $key => $value) {
$this->{$key} = $value;
}
}
require Config::get('PATH_VIEW') . '_templates/header.php';
require Config::get('PATH_VIEW') . $filename . '.php';
require Config::get('PATH_VIEW') . '_templates/footer.php';
}
の上には、Viewクラスについてお知らせするためのノートです。私ImageModelで
public function index()
{
$this->View->render('index/index', array(
'images' => ImagesModel::getImages())
);
}
:私のIndexCotrollerで
インデックス/インデックスビューで
class ImageModel
{
/**
*
*
*/
public static function getImages($xxx)
{
$xxx = "test test test";
}
}
私が持っている:
<?php $this->images; ?>
は、私のようなエラーが表示されます。
Warning: Missing argument 1 for ImageModel::getImages(), called in IndexController.php on line 21 and defined in ImageModel.php on line 13
変数をエコーして、モデルからインデックスビューにデータを取得できることをテストするだけです。私はPHPには非常に新しいです、確かに私が噛むことができますが、これは私に挑戦すること以上知っている必要があります。
私の関数と配列は不気味ですか?私を燃やすが、あまりにも知識を提供するか?
'images; ?> 'それはエコーでしょうか?それは何もしていないようです。 – RiggsFolly
'ImagesModel :: getImages()'メソッドでパラメータを定義しました!しかし、あなたはこの呼び出しで1つを渡すことはありません。 _そのメソッドは '$ xxx = somthing_ – RiggsFolly
を設定するのではなく、何かを' return'するべきですか?私のモデルからインデックスビューにデータを取得できることをテストする変数をエコーしたいだけです。 '$ xxx =" test test test "を置き換えます。 '返す"テストテストテストで ";そして、少なくとも今のところ、そのメソッドのパラメータを緩める – RiggsFolly