strip_tags (PHP 3>= 3.0.8, PHP 4 )strip_tags -- Strip HTML and PHP tags from a string Description string strip_tags ( string str [, string allowable_tags]) This function tries to return a string with all HTML and PHP tags stripped from a given str. It errors on the side of caution in case of incomplete or bogus tags. It uses the same tag stripping state machine as the fgetss() function. You can use the optional second parameter to specify tags which should not be stripped. 注: allowable_tags was added in PHP 3.0.13 and PHP 4.0b3. 例子 1. strip_tags() example<?php $string = strip_tags($string, '<a><b><i><u>'); ?>
$m_Contents = "<TABLE borderColor=#c0c0c0 cellSpacing=0 cellPadding=2 bgColor=#ffffff border=1></Table>";
$m_Contents = preg_replace("/<table.*>/isU", "", $m_Contents);
echo $m_Contents;
?>
(PHP 3>= 3.0.8, PHP 4 )strip_tags -- Strip HTML and PHP tags from a string
Description
string strip_tags ( string str [, string allowable_tags])
This function tries to return a string with all HTML and PHP tags stripped from a given str. It errors on the side of caution in case of incomplete or bogus tags. It uses the same tag stripping state machine as the fgetss() function. You can use the optional second parameter to specify tags which should not be stripped. 注: allowable_tags was added in PHP 3.0.13 and PHP 4.0b3.
例子 1. strip_tags() example<?php
$string = strip_tags($string, '<a><b><i><u>');
?>
$m_Contents = "<TABLE borderColor=#666666 cellSpacing=0 cellPadding=0 bgColor=#e6e6e6></Table>";
$m_Contents = preg_replace("/<table.*>/isU", "", $m_Contents);
echo $m_Contents;
?>
$trans = get_html_translation_table(HTML_ENTITIES);
$str = "<B>哈哈</B>";
$encoded = strtr($str, $trans);
?>