fgetss
(php 4, php 5, php 7)
fgetss — 从文件指针中读取一行并过滤掉 html 标记
说明
string fgetss ( resource $handle [, int $length [, string $allowable_tags ]] )
和 fgets() 相同,只除了 fgetss() 尝试从读取的文本中去掉任何 html 和 php 标记。
参数
handle
文件指针必须是有效的,必须指向由 fopen() 或 fsockopen() 成功打开的文件(并还未由 fclose() 关闭)。
length
取回该长度的数据。
allowable_tags
可以用可选的第三个参数指定哪些标记不被去掉。
返回值
从 handle 指向的文件中大读取 length - 1 个字节的字符,并过滤了所有的 html 和 php 代码。
错误发生时返回 false。
$str =
Welcome! Today is the of .
Text outside of the HTML block.
EOD;
file_put_contents('sample.php', $str);
$handle = @fopen("sample.php", "r");
if ($handle) {
while (!feof($handle)) {
$buffer = fgetss($handle, 4096);
echo $buffer;
}
fclose($handle);
}
?>
Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号