我有一个函数用于去除不需要的HTML标签。
例如:
当我将'<'字符传递给strip_tags时,它返回空值。然而,如果我传递'>',strip_tags会返回正确的字符。
我需要能够从上面的调用中返回'<'。你有什么解决办法吗?
function getValidStrings($inputStr, $allowedTag) {
return trim(strip_tags($inputStr, $allowedTag));
} // End function
// Here I am calling this function which is defined in an included php Class file
$formatter = new $StringTextFormatter;
$validString = $formatter->getValidStrings('<', '<br>');
// The $validString has empty string "" ... Why ?
当我将'<'字符传递给strip_tags时,它返回空值。然而,如果我传递'>',strip_tags会返回正确的字符。
我需要能够从上面的调用中返回'<'。你有什么解决办法吗?
<
不是一个标签。你想做什么? - AbraCadaver>
开头,所以这是有道理的,是的。有点儿。我能理解你为什么问了。 - Clive