PHP fgetss() 函數
定義和用法
fgetss() 函數從打開的文件中返回一行,並過濾掉HTML 和PHP 標籤。
fgetss() 函數會在到達指定長度或讀到文件末尾(EOF)時(以先到者為準),停止返回一個新行。
如果失敗該函數返回FALSE。
語法
fgetss(file,length,tags)
参数 | 描述 |
---|---|
file | 必需。规定要检查的文件。 |
length | 可选。规定要读取的字节数。默认是 1024 字节。 注意:该参数在 PHP 5 之前的版本是必需的。 |
tags | 可选。指定将被删除的标签。 |
實例1
<?php
$file = fopen("test.htm","r");
echo fgetss($file);
fclose($file);
?>
$file = fopen("test.htm","r");
echo fgetss($file);
fclose($file);
?>
上面的代碼將輸出:
This is a paragraph.
實例2
<?php
$file = fopen("test.htm","r");
echo fgetss($file,1024,"<p>,<b>");
fclose($file);
?>
$file = fopen("test.htm","r");
echo fgetss($file,1024,"<p>,<b>");
fclose($file);
?>
上面的代碼將輸出:
This is a paragraph.
上面輸出的源代碼是:
<p><b>This is a paragraph.</b></p>
完整的PHP Filesystem參考手冊