开发者

How mvc works in Zend framework

Thanks for previous replies..

I am trying to print Hello_world using zend framework. I wrote php file in model folder开发者_C百科 and return string value as a "Hello_world". In controller i access the value of PHP like this

$value = new TextReturner(); $this->view->setValue = $value->hello_world(); . i dont know how to access the value from controller to the view php file. I am new to zend framework. I already go through the outline structure of zend framework, i dont know how to access through codings. If anyone have idea of how to print hello_world through MVC pls guide me.


You are trying to use class $value = new TextReturner(); but your controller doesn't see that class.

Set this in your Bootstrap file that will help:

protected function _initAutoLoad() {
    // Add autoloader empty namespace
    $autoLoader = Zend_Loader_Autoloader::getInstance();
    $resourceLoader = new Zend_Loader_Autoloader_Resource(
            array(
                'basePath'      => APPLICATION_PATH,
                'namespace'     => '',
                'resourceTypes' => array(
                'model'         => array(
                        'path'      => 'models/',
                        'namespace' => 'Model_'
                    ),
                ),
            )
    );
    return $resourceLoader;
}

This will be autoload all of your model class.


in view you can access your variable like this:

<?php echo $this->setValue;?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜