如何从控制器获取值
我正在尝试打印你好世界。
为此,我在模型文件夹中创建了类和返回函数,返回值为“hello world”。
在控制器中,我从模块中获取值,如下所示:
$value = new getValue();
$this->view->index = $value->hello_world();
I don't know how to get the values from controllers and print into views php folder.I am trying to print hello world.
For that i created class and return function in models folder, and the returning value is "hello world".
In controller, i am getting the values from module like this:
$value = new getValue();
$this->view->index = $value->hello_world();
I don't know how to get the values from controllers and print into views php folder.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事实上,当您执行此操作时,您将“Hello world”字符串放入控制器视图的变量“index”中
$this->view->index = $value->hello_world();.
因此,如果您的
$value->hello_world();
函数正确返回一个“Hello world”字符串,为了将其打印到控制器的视图中,您只需添加此 php 代码将 $this->index;
回显到您的视图文件中。In fac, you put "Hello world" string into the variable "index" of the controller's view when your are doing this
$this->view->index = $value->hello_world();
.So, if your
$value->hello_world();
function correctly return an "Hello world" string, for print it into the controller's view, you just have to do add this php codeecho $this->index;
into your view file.我真的认为你应该首先阅读教程。仅仅通过立即开始编码来尝试弄清楚 Zend Framework 的工作原理可能相当困难。
I really think you should read a tutorial first of all. It can be quite hard to try to figure out how Zend Framework works just by starting to code right away.