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 CodeThe code is as follows:
$str = ' Guo Bowl scoop Basin- PHP';
$str 1 = strip_tags ($STR); Delete all HTML tags
$str 2 = strip_tags ($str, ' '); Keep Tags
echo $str 1;//output Guo Bowl-php
Echo $str 2;//style is different oh
Example 2, clearing some property codes in HTML tag strings
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 HTML pages.
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);
?
http://www.bkjia.com/phpjc/825086.html www.bkjia.com True http://www.bkjia.com/phpjc/825086.html techarticle