Usually we use Htmlspecialchars () to filter HTML, but the character of the HTML is escaped, the final display is the HTML source code.
Use Strip_tags () to get rid of HTML tags.
$str = ' href ';
echo Htmlspecialchars ($STR);
echo Strip_tags ($STR);
?>
Many of the home page has a small part of the article. Use Strip_tags () to remove HTML tags here. But we also have to consider what the code is, because the normal cutting field string is easy to cut the last character into half.
/**
* Intercept Utf-8 string
* @since 2008.12.23
* @param string $str intercepted
* @param integer $start starting position
* @param integer $length intercept Length (3 bytes per kanji)
*/
function Utf8_strcut ($str, $start, $length =null) {
Preg_match_all ('/./us ', $str, $match);
$chars = Is_null ($length)? Array_slice ($match [0], $start): Array_slice ($match [0], $start, $length);
Unset ($STR);
Return implode (", $chars);
}