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.
<<
is not a tag, you have to use a regex (with preg_replace()
for example) or str_replace()
to escape it.