视图中的CodeIgniter助手 [英] CodeIgniter helper in the view
问题描述
这是一个好的解决方法,并且可以在CodeIgniter的视图中使用帮助器类。我遇到一种情况,当我必须从一对字符串文本中提取正则表达式并在匹配项上生成输出时。我不想直接在视图中执行此操作,因此我想使用一个帮助程序。
Is it a good workaround and would it be possible to use helper classes in the view, in CodeIgniter. I have a situation when I have to extract with regulars expression from a text couple of strings and generate outputs on matches. I would not like to do this directly in the view and I would like to use for this purpose a helper.
application
--view
---myview.php
在这里,我应该将帮助程序并返回结果
and here I should call the helper and return results
例如,我想从文本中提取处理器的类型,而不是传递文本并返回处理器的类型。之所以需要这个,是因为视图中的所有数据都是由API动态生成的。
for example I want to extract from the text the type of processor, than I pass the text and get returned the processor type. This one is needed because all the data in the view are generated by an API dynamically.
echo $myhelper->processor($text);
推荐答案
get_instance()->load->helper('HELPER_NAME');
这篇关于视图中的CodeIgniter助手的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!