fgetss 函数不同于传统文件函数并使您能更好地了解 PHP 的力量。该函数的功能类似于 fgets 函数,但将去掉发现的任何 HTML 或 PHP 标记,只留下纯文本。查看如下所示的 HTML 文件。
fgetss 函数不同于传统文件函数并使您能更好地了解 PHP 的力量。该函数的功能类似于 fgets 函数,但将去掉发现的任何 HTML 或 PHP 标记,只留下纯文本。查看如下所示的 HTML 文件。
清单 2. 样例 HTML 文件
<html> <head><title>My title</title></head> <body> <p>If you understand what "Cause there ain't no one for to give you no pain" means then you listen to too much of the band America</p> </body> </html>
|
然后通过 fgetss 函数过滤它。
清单 3. 使用 fgetss
$file_handle = fopen("myfile", "r"); while (!feof($file_handle)) { echo = fgetss($file_handle); } fclose($file_handle);
|
以下是输出:
My title
If you understand what "Cause there ain't no one for to give you no pain"
means then you listen to too much of the band America