如何修复这个在聊天中显示笑脸的小错误,以及在聊天中用星号替换咒骂


How to fix this small bug of displaying smileys in chat, and replacing swears with asterisks in chat?

大家好,我的网站有一个聊天框,并且已经内置了笑脸符号功能,但是没有"诅咒过滤器",所以我决定今天尝试添加它。下面是聊天框的输出:

$return .= "<div style='"font-size: 14px; padding-bottom: 3px; color: #444444;'">". $time     . $icon . $username . str_replace('"', "'", parse_bbcode(smiley(str_replace("'n", '',     $chat['text'])))) ."</div>";

在末尾显示:

str_replace('"', "'", parse_bbcode(smiley(str_replace("'n", '',     $chat['text']))))

我已经用诅咒替换了smiley,只是为了测试一下,诅咒函数工作得很好,但我想知道如何才能同时显示smiley和诅咒函数,而不是只有一个。

我试过:

parse_bbcode(smiley, curses
parse_bbcode(smiley . curses

却没有运气....

下面是我的parse_bbcode函数:
function parse_bbcode($text, $xhtml = true) {
        $tags = array(
                '#'[b'](.*?)'[/b']#si' => ($xhtml ? '<strong>''1</strong>' : '<b>''1</b>'),
                '#'[i'](.*?)'[/i']#si' => ($xhtml ? '<em>''1</em>' : '<i>''1</i>'),
                '#'[u'](.*?)'[/u']#si' => ($xhtml ? '<span style="text-decoration: underline;">''1</span>' : '<u>''1</u>'),
                '#'[s'](.*?)'[/s']#si' => ($xhtml ? '<strike>''1</strike>' : '<s>''1</s>'),
                '#'[color=(.*?)'](.*?)'[/color']#si' => ($xhtml ? '<span style="color: ''1;">''2</span>' : '<font color="''1">''2</font>'),
                '#'[img'](.*?)'[/img']#si' => ($xhtml ? '<img src="''1" border="0" alt="" style="max-width: 400px; max-height: 200px;" />' : '<img src="''1" border="0" alt="">'),
                '#'[url=(.*?)'](.*?)'[/url']#si' => '<a href="''1" target="_blank" style="color: #000000; font-size: 12px;" title="''2">''2</a>',
                '#'[email'](.*?)'[/email']#si' => '<a href="mailto:''1" title="Email ''1">''1</a>',
                '#'[code'](.*?)'[/code']#si' => '<code>''1</code>',
                '#'[align=(.*?)'](.*?)'[/align']#si' => ($xhtml ? '<div style="text-align: ''1;">''2</div>' : '<div align="''1">''2</div>'),
                '#'[br']#si' => ($xhtml ? '<br style="clear: both;" />' : '<br>'),
        );
        foreach ($tags AS $search => $replace) {
                $text = preg_replace($search, $replace, $text);
        }
        return $text;
}

Oh my…

... parse_bbcode(curses(smiley(...