CodeIgniter,如何在发送之前修改缓冲输出 [英] CodeIgniter, How to modify buffered output before sending

查看:153
本文介绍了CodeIgniter,如何在发送之前修改缓冲输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想改变整个Codeigniter网站的输出。

I would like to alter the output throughout my Codeigniter-based website.

很简单我想做

$output = str_replace(
    array('ā','ē','ī','ō','ū','Ā','Ē','Ī','Ō','Ū'),
    array('a','e','i','o','u','A','E','I','O','U'),
    $output
)



<

In the event that the user prefers so.

通过阅读问题和答案,我发现了一个可以帮助...的链接。

By reading questions and answers here, I found a link that could help..

https://ellislab.com/codeigniter/ user-guide / general / controllers.html#output

..但是它只能通过控制器来控制,而且会重复内容。

..but it only works controller by controller and that would be repetition of content.

有没有办法改为挂钩?

提前感谢!

推荐答案

如果你的意图是替换重音字符,我建议你看看wordpress remove_accents函数此处

If your intention is to replace accented characters then i suggest you take a look at wordpress remove_accents function here.

2) a href =https://ellislab.com/codeigniter/user-guide/general/hooks.html =nofollow> codeigniter钩子,有display_override钩子

2) take a look at codeigniter hooks, there is display_override hook

$hook['display_override'] = array(
  'class'    => 'MyClass',
  'function' => 'Myfunction',
  'filename' => 'Myclass.php',
  'filepath' => 'hooks',
  'params'   => array()
);

3)一旦为这个钩子定义了一个函数/类, p>

3) once you define a function/class for this hook, you could get output string there

$this->CI =& get_instance();
$out = $this->CI->output->get_output();

,然后您可以随意更改输出...

and then you can change the output as you like...

这篇关于CodeIgniter,如何在发送之前修改缓冲输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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