Example 1, PHP's own function can remove/delete the HTML tag/code in the string.
Strip_tags (String,allow): The function strips HTML, XML, and PHP tags.
Parameters: String, required, specifies the string to check, allow, optional, specify the allowed tags, these tags will not be deleted.
Copy the Code code as follows:
$str = ' Guo Bowl pot- PHP';
$str 1 = strip_tags ($STR); Delete all HTML tags
$str 2 = strip_tags ($str, " );//reserved label
echo $str 1; Output Guo Bowl scoop basin-php
echo $str 2; Not the same style!
Example 2, clearing some property codes in an HTML tag string
Using PHP to process the HTML code of the article read from the database, and then use regular code to match and modify, save the code, the static generation function can be generated after the modified HTML page.
Because the code we generate is code that has already been processed, it does not affect the loading speed of the HTML page.
The specific [sample code] is as follows:
Copy the Code code as follows:
$str = "";
$str = Preg_replace (' #onclick = ([ss]*) ' # ', ' ', $str);
#符号前面有一个双引号要注意, the code that represents the end
Print ($STR);
?>