Php 获得额外收入<;b>;输出中的标记
我正在使用codeigniter v3.x 现在我创建了一个函数来加载带有模板的视图Php 获得额外收入<;b>;输出中的标记,php,codeigniter,view,Php,Codeigniter,View,我正在使用codeigniter v3.x 现在我创建了一个函数来加载带有模板的视图 function load_guest($view,$data=array('data'=>''),$headerdata=array('data'=>''),$PageTitle='',$PageKeywords='',$PageDescription=''){ $CI = & get_instance(); //get instance, access the
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');
}
函数加载\u guest($view,$data=array('data'=>''),$headerdata=array('data'=>''),$PageTitle='',$PageKeywords='',$PageDescription=''){
$CI=&get_instance();//获取实例,访问CI超对象
$headerdata['title']=$PageTitle;
$headerdata['keyword']=$PageKeywords;
$headerdata['description']=$PageDescription;
$CI->load->view('partial/head',$headerdata);
//在这里,我得到了html输出的开始标记
$CI->load->view($view,$data);
//这里我得到了html输出的结束标记
$CI->load->view(“部分/英尺”);
}
但当我在浏览器上加载任何页面后看到html源代码时。我在源代码中看到一对
标记
我检查了整个项目并搜索了
标记,我确信我没有在任何地方使用
标记
我使用Phpstorm,所以我在路径中找到了
标记,但没有找到任何内容
编辑
我也在用钩子
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();
}
函数压缩()
{
ini_集(“pcre.递归极限”,“16777”);
$CI=&get_instance();
$buffer=$CI->output->get_output();
$re='%#将空格折叠到除黑名单元素外的所有位置。
(?>#匹配除单个空格外的所有空格。
[^\S]\S*#一个[\t\r\n\f\v]和零个或多个ws,
|\s{2,}#或两个或多个连续的任意空格。
)#注意:剩余的正则表达式完全不使用文本。。。
(?=#确保我们没有被列入黑名单。
[^我能用一个懒惰的技巧解决这个问题
在hook compress()函数中,我手动替换所有
标记
$new_buffer = str_replace("<b>","",$new_buffer);
$new_buffer = str_replace("</b>","",$new_buffer);
$new_buffer = str_replace("</ b>","",$new_buffer);
$new\u buffer=str\u replace(“,”,$new\u buffer);
$new\u buffer=str\u replace(“,”,$new\u buffer);
$new\u buffer=str\u replace(“,”,$new\u buffer);
这部分解决了我的问题。但我仍然想知道,有更好的解决方案吗?对不起,我的英语不好…视图文件“partial/foot”、“partial/head”和$view如何?@oleksandrkhavdy它们只是我模板的Html文件(partial/head和partial/foot)$view是要加载的主视图。是的,这些文件将抛出htmltoo@OleksandrKhavdiy什么意思?