PHP 教程
fgetss() 函數(shù)從打開的文件中返回一行,并過濾掉 HTML 和 PHP 標(biāo)簽。
fgetss() 函數(shù)會在到達(dá)指定長度或讀到文件末尾(EOF)時(以先到者為準(zhǔn)),停止返回一個新行。
如果失敗該函數(shù)返回 FALSE。
參數(shù) | 描述 |
---|---|
file | 必需。規(guī)定要檢查的文件。 |
length | 可選。規(guī)定要讀取的字節(jié)數(shù)。默認(rèn)是 1024 字節(jié)。 注意:該參數(shù)在 PHP 5 之前的版本是必需的。 |
tags | 可選。指定哪些標(biāo)記不被去掉。 |
test.html 代碼內(nèi)容:
<p><b>This is a paragraph.</b></p>
PHP 代碼:
<?php $file = fopen("test.html","r"); echo fgetss($file); fclose($file); ?>
上面的代碼將輸出:
This is a paragraph.
<?php $file = fopen("test.html","r"); echo fgetss($file,1024,"<p>,<b>"); fclose($file); ?>
上面的代碼將輸出:
上面輸出的源代碼是:
<p><b>This is a paragraph.</b></p>