使用数组将参数传递给 HMVC 模块方法
在 Codeignitors 中使用 HMVC 组件时,我们可以呈现这样的特定操作,
echo modules::run('site/news/view', 1);
这里 1
是发送到视图方法的参数。
现在我有一个参数数组,我需要将其传递给函数
$params = array(1, "latest", "desc"); //suppose this are the parameters I received dynamically some how and dont knows its length
现在,我需要单独发送这些参数,就像
echo modules::run('site/news/view', 1, "latest", "desc");
在其他函数中一样 call_user_func_array()
在这种情况下不起作用(我认为) 。
While using the HMVC Component in Codeignitors, we can render a particular actions like this
echo modules::run('site/news/view', 1);
Here the 1
is the parameter send to the view method.
Now I have an array of parameters, which i need to pass to the function
$params = array(1, "latest", "desc"); //suppose this are the parameters I received dynamically some how and dont knows its length
Now, I need to send these parameters seperately as
echo modules::run('site/news/view', 1, "latest", "desc");
Like in other functions call_user_func_array()
will not work at this case(I think).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,不可能让现有函数按照您需要的方式工作(除非进行修改)。您应该以函数已经可用的方式进行编码。如果它不能按您需要的方式工作,请在允许的情况下修改源代码,或者编写您自己的版本,或扩展主类,以满足您的需求。
我可以很容易地回答这个问题,但这次我希望你也能这样做。我之前已经回答过你的问题了&刚刚查看了您的个人资料,6 个问题(已接受 1 个)0 个答案,并且对于大多数问题,您没有提供任何信息。看来你自己什么也做不了。
你依靠这个社区来完成你的工作,这是非常不公平的。所以除非你给我看你的一些作品,否则我拒绝回答。
Well, its not possible to make an existing function work the way you need (unless modified). You should code, the way THE FUNCTION ALREADY WORKS. If it does not work the way you need, modify the source if allowed, or else write you own version of it, or extend the main class, to fit your needs.
I could answer this question easy, but this time I will want you to do the same. I have answered your question before & just viewed your profile, 6 Questions (1 accepted) 0 answers and on most of the questions no input from your side. You don't seem to do anything on your own.
You relying on this community to get your job done, which is so unfair. So UNLESS you show me some of your work, I refuse to answer.
我创建了一个“seo 前端控制器”,我(残酷地)以这种方式解决了同样的问题
I created a "seo front controller" and I (brutally) resolved the same problem in ths way