how to hide html tags without remove it in php for

2019-06-12 14:07发布

问题:

im getting stuck when i save string with paragraph, and the html tags <p></p> and <br></br> is come to save into database, if i use strip_tags() the string is being RAW.. anyone can help me pleasee.. sorry for my poor english

回答1:

if you need to have exceptions for your tags you can do

strip_tags($string,"<p><br>");

this will remove all tags except p and br.

to escape a string you can use

mysql_real_escape_string($str);

or just

addslashes($str);


回答2:

The strip_tags() function takes a second argument:

string strip_tags ( string $str [, string $allowable_tags ] )

If you specify which tags you want saved (e.g., strip_tags($text, '<p><br>');), it will not remove those tags.



回答3:

u can use strip_tags();

and also possible to use jq; its very easy and efective,, u can use

$('<p>').attr('disabled',"disabled"");

if u any help comment my link i ll tell u