PHP fgetss() 函数

PHP 教程 · 2019-01-24 20:58:10

定义和用法

fgetss() 函数从打开的文件中返回一行,并过滤掉 HTML 和 PHP 标签。

fgetss() 函数会在到达指定长度或读到文件末尾(EOF)时(以先到者为准),停止返回一个新行。

如果失败该函数返回 FALSE。

语法


fgetss(file,length,tags)


参数 描述
file 必需。规定要检查的文件。
length 可选。规定要读取的字节数。默认是 1024 字节。

注意:该参数在 PHP 5 之前的版本是必需的。

tags 可选。指定哪些标记不被去掉。

实例

实例 1

test.html 代码内容:

<p><b>This is a paragraph.</b></p>

PHP 代码:

<?php
$file = fopen("test.html","r");
echo fgetss($file);
fclose($file);
?>

上面的代码将输出:

This is a paragraph.

实例 2

<?php
$file = fopen("test.html","r");
echo fgetss($file,1024,"<p>,<b>");
fclose($file);
?>

上面的代码将输出:


This is a paragraph.

上面输出的源代码是:

<p><b>This is a paragraph.</b></p>

点击查看所有 PHP 教程 文章: https://codercto.com/courses/l/5.html

查看所有标签

Web Analytics

Web Analytics

Avinash Kaushik / Sybex / 2007-6-5 / USD 29.99

在线阅读本书 Written by an in-the-trenches practitioner, this step-by-step guide shows you how to implement a successful Web analytics strategy. Web analytics expert Avinash Kaushik, in his thought-p......一起来看看 《Web Analytics》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换