如何从视图中调用codeigniter控制器函数 [英] How to call codeigniter controller function from view

查看:113
本文介绍了如何从视图中调用codeigniter控制器函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从视图调用codeigniter控制器函数?当我调用控制器中的函数,得到一个404页面。

How to call codeigniter controller function from view? When i call the function in a controller, get a 404 page.

推荐答案

Codeigniter是一个MVC(模型 - 视图 - 框架。从视图调用函数真的不是一个好主意。该视图应该只用于演示,所有的逻辑应该发生之前,你的控制器和模型的视图。

Codeigniter is an MVC (Model - View - Controller) framework. It's really not a good idea to call a function from the view. The view should be used just for presentation, and all your logic should be happening before you get to the view in the controllers and models.

一个好的开始澄清最好实践是遵循本教程:

A good start for clarifying the best practice is to follow this tutorial:

http: //ellislab.com/codeigniter/user-guide/tutorial/index.html

这很简单,但它确实提供了一个很好的操作方法。

It's simple, but it really lays out an excellent how-to.

我希望这有助于!

这篇关于如何从视图中调用codeigniter控制器函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆