fgetss()函數(shù)可以返回從打開的文件中,過濾掉 HTML 和 PHP 標(biāo)記的一行。 此函數(shù)可以停止返回指定長度或EOF(以先出現(xiàn)的為準(zhǔn))的新行,并在失敗時返回False。
string fgetss ( resource $handle [, int $length [, string $allowable_tags ]] )
該函數(shù)類似于fgets()函數(shù),不同之處在于fgetss()函數(shù)可以嘗試從讀取的文本中過濾掉所有HTML和PHP標(biāo)記。
<?php
$handle = @fopen("/PhpProject/test.php", "r");
if ($handle) {
while (!feof($handle)) {
$buffer = fgetss($handle, 4096);
echo $buffer;
}
fclose($handle);
}
?>輸出結(jié)果
Welcome to (cainiaoplus.com)
<?php
$handle = @fopen("/PhpProject/test.php", "r");
if ($handle) {
while (!feof($handle)) {
$buffer = fgetss($handle, 4096, ", ");
echo $buffer;
}
fclose($handle);
}
?>