Example 1, PHP's own functions can remove/remove HTML tags/code in the string.
Strip_tags (String,allow): Functions strip HTML, XML, and PHP tags.
Parameters: String, required, specify the strings to be checked, allow, optional, specify the labels that are allowed to exist, and these tags will not be deleted.
Copy Code code as follows:
$str = ' Guo Bowl ladle-<span style= ' color: #f00; >PHP</span> ';
$str 1 = strip_tags ($STR); Delete all HTML tags
$str 2 = strip_tags ($str, ' <span> '); Reservations <span> Labels
echo $str 1; Output Guo Bowl scoop basin-php
echo $str 2; It's not the same style!
Example 2, clear some of the property codes in the HTML tag string
Use PHP to process the text from the database read the HTML code, and then use the regular code to match and modify, save the code, with the static build function can be generated after the modified HTML page.
Because the code we generate is code that has been processed, it does not affect the speed at which HTML pages are loaded.
Specific [sample code] is as follows:
Copy Code code as follows:
<?php
$str = "$str = Preg_replace (' #onclick = ([ss]*) ' # ', ', $str];
#符号前面有一个双引号要注意, representing the end of the code
Print ($STR);
?>