单词过滤器,替换为内容发送

时间:2014-05-03 12:19:59

标签: php

所以我知道ob_start()阻止了web服务器在调用ob_flush()之前发送任何内容,但是如何在刷新之前替换页面上的所有脏话呢?

2 个答案:

答案 0 :(得分:1)

如果我理解你需要:

Demo.

ob_start();
echo "some text here and here\r\n";
echo "some second text here and here\r\n";
$out = ob_get_clean();
echo $out."\r\n\r\n";
echo str_replace('here', 'there', $out);

答案 1 :(得分:1)

你不应该在整个页面中这样做,因为它很难分析。 (例如,如果有人用变量'ck'和'f'写了一个JS,你真的搞砸了他们的产品f * ck?)在HTML中你很容易被fK ck或fu<! - 欺骗。 - n - > ck。

当您显示(甚至更好地:保存)用户生成的内容(例如评论)并仅过滤那些内容时,设置过滤器。