dqkxo44488 2016-04-25 05:59
浏览 32

在输出中获取额外的<b>标记

I am using codeigniter v 3.x

Now I make a function to load viewes with templates

    function load_guest($view,$data=array('data'=>''),$headerdata=array('data'=>''),$PageTitle='',$PageKeywords='',$PageDescription=''){
        $CI = & get_instance();  //get instance, access the CI superobject
        $headerdata['title']=$PageTitle;
        $headerdata['keyword']=$PageKeywords;
        $headerdata['description']=$PageDescription;
        $CI->load->view('partial/head',$headerdata);
        //Here i am getting opening <b> tag on html output
        $CI->load->view($view,$data);
        //Here i am getting closing </b> tag on html output
        $CI->load->view('partial/foot');
    }

But when I see the html source after loading any page on browser. I see a pair of <b></b> tag into the source.

I checked my whole project and search for <b> tag and I am sure I am not using <b> tag anywhere.

I use Phpstorm so I find in path for <b> tag and nothing found...

EDIT I am using a hook also

function compress()
{

    ini_set("pcre.recursion_limit", "16777");
    $CI =& get_instance();
    $buffer = $CI->output->get_output();
    $re = '%# Collapse whitespace everywhere but in blacklisted elements.
        (?>             # Match all whitespans other than single space.
          [^\S ]\s*     # Either one [\t
\f\v] and zero or more ws,
        | \s{2,}        # or two or more consecutive-any-whitespace.
        ) # Note: The remaining regex consumes no text at all...
        (?=             # Ensure we are not in a blacklist tag.
          [^<]*+        # Either zero or more non-"<" {normal*}
          (?:           # Begin {(special normal*)*} construct
            <           # or a < starting a non-blacklist tag.
            (?!/?(?:textarea|pre|script)\b)
            [^<]*+      # more non-"<" {normal*}
          )*+           # Finish "unrolling-the-loop"
          (?:           # Begin alternation group.
            <           # Either a blacklist start tag.
            (?>textarea|pre|script)\b
          | \z          # or end of file.
          )             # End alternation group.
        )  # If we made it here, we are not in a blacklist tag.
        %Six';

    $new_buffer = preg_replace($re, " ", $buffer);
      // We are going to check if processing has working
    if ($new_buffer === null)
    {
        $new_buffer = $buffer;
    }

    $CI->output->set_output($new_buffer);
    $CI->output->_display();
}
  • 写回答

1条回答 默认 最新

  • drk7700 2016-04-25 06:30
    关注

    I am able to solve this problem using a lazy trick.

    In hook compress() function I replace all <br> tag manually.

    $new_buffer = str_replace("<b>","",$new_buffer);
    $new_buffer = str_replace("</b>","",$new_buffer);
    $new_buffer = str_replace("</ b>","",$new_buffer);
    

    This partially solves my problem. But I still want to know, is there a better solution for this?

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?