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

查看:36
本文介绍了如何从视图中调用 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:

https://codeigniter.com/user_guide/tutorial/index.html

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

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

我希望这会有所帮助!

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

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