你可以从CakePHP中的视图调用控制器函数吗? [英] Can you call a controller function from a view in CakePHP?

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

问题描述

我想从视图中调用控制器函数。
在Cake PHP中是可能的吗?

I want to call a controller function from a view. Is that possible in Cake PHP?

推荐答案

可以通过 requestAction方法,但由于性能受到轻微影响,因此不建议使用。

It is possible via the requestAction method, but it is not recommended due to a slight performance hit. Use it wisely.

由于评论中注明的 Xr ,使用requestAction通常表示设计问题(MVC分隔)。

As Xr noted in the comment, using requestAction often signifies design issues (MVC separation).

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

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