csdn的代码高亮有问题
public function transform($txt)
    {
        $txt = trim($txt);
        $txt = addslashes(htmlspecialchars($txt, ENT_QUOTES, "UTF-8"));
        if (preg_match_all("/\
Quote:
(.+?)\[\/quote]/is", $txt, $match)) {
            $txt = preg_replace('/\s*\r\n\s*/', '', $txt, 1);
        }
        $huanhang = array(
            "\r\n",
            "\n",
            "\r"
        );
        $txt      = str_replace($huanhang, '<br>', $txt);

解决方案 »

  1.   

    public function transform($txt)
        {
            $txt = trim($txt);
            $txt = addslashes(htmlspecialchars($txt, ENT_QUOTES, "UTF-8"));
            if (preg_match_all("/\
    Quote:
    (.+?)\[\/quote]/is", $txt, $match)) {
                $txt = preg_replace('/\s*\r\n\s*/', '', $txt, 1);
            }
            $huanhang = array(
                "\r\n",
                "\n",
                "\r"
            );
            $txt      = str_replace($huanhang, '<br>', $txt);
      

  2.   

    我在最后输出来的时候又加了这个
    $txt = preg_replace('/\s{2,}/', ' ', $txt);
    不知道行不行了?
      

  3.   

    再说你的 transform 方法也没有检查长度