简体   繁体   中英

strip_tags is not allowing << and >> in php

Hi i am trying to allow html tags in a string using strip_tags in php

But my string contains "<<" and ">>" and i am trying to allow those things using below code:

$allowTags = "<<>><span><s><strike><del><bdo><big><small><ins><cite><acronym><font><sup><sub><b><u><i><a><strong><em><code><samp><tt><kbd><var><q><table><thead><tfoot><tbody><tr><th><td><ol><ul><li><dl><dt><dd><form><input><select><textarea><option><div><p><h1><h2><h3><h4><h5><h6><pre><center><blockquote><address><hr><img><br><indexentry><indexinsert><bookmark><watermarktext><watermarkimage><tts><ttz><tta><column_break><columnbreak><newcolumn><newpage><page_break><pagebreak><formfeed><columns><toc><tocentry><tocpagebreak><pageheader><pagefooter><setpageheader><setpagefooter><sethtmlpageheader><sethtmlpagefooter><annotation><template><jpgraph><barcode><dottab><caption><textcircle><fieldset><legend><article><aside><figure><figcaption><footer><header><hgroup><nav><section><mark><details><summary><meter><progress><time>";

$test = "<span>white</span>red<<blue";
file_put_contents("test.log", print_r($test,true),FILE_APPEND);
$text = strip_tags($test, $allowTags);
file_put_contents("test.log", print_r($text,true),FILE_APPEND);

But its not working i am getting output as <span>white</span>red and expected output is <span>white</span>red<<blue

Please help me to resolve the issue. Thanks in advance.

<<不是标记,必须使用正则表达式(例如,带有preg_replace() )或str_replace()进行转义。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM