Usually we use Htmlspecialchars () to filter the HTML, but the HTML characters escaped, the final display is the HTML source code.
You can use Strip_tags () to get rid of HTML tags.
$str = ' href ';
echo Htmlspecialchars ($STR);
echo Strip_tags ($STR);
?>
Many home pages have a small part of the article. Use Strip_tags () to get rid of HTML tags here. But we have to consider what the code is, because the normal cut field string can easily cut the last character into half.
/**
* Intercept Utf-8 string
* @since 2008.12.23
* @param string $str the truncated strings
* @param integer $start start 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);
}
http://www.bkjia.com/PHPjc/788518.html www.bkjia.com true http://www.bkjia.com/PHPjc/788518.html techarticle usually we use Htmlspecialchars () to filter the HTML, but the HTML characters escaped, the final display is the HTML source code. Use Strip_tags () to get rid of HTML tags ....