>我正在使用codeigniter v 3.x
现在我做了一个函数来加载带有模板的视图
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');
}
但是当我在浏览器上加载任何页面后看到 html 源代码时。我在源中看到一对<b></b>
标签。
我检查了我的整个项目并搜索了<b>
标签,我确定我没有在任何地方使用<b>
标签。
我使用 Phpstorm,所以我在路径中找到<b>
标签,但什么也没找到......
编辑我也在使用钩子
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'r'n'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();
}
我可以使用懒惰的技巧来解决这个问题。
在钩子压缩()函数中,我手动替换了所有<br>
标签。
$new_buffer = str_replace("<b>","",$new_buffer);
$new_buffer = str_replace("</b>","",$new_buffer);
$new_buffer = str_replace("</ b>","",$new_buffer);
这部分解决了我的问题。但我仍然想知道,有没有更好的解决方案?