fgetss() function in PHP
fgestss() function gets a line from the file pointer and strips HTML and PHP tags. The fgetss() function returns a string of maximum length 1 byte read from the file pointed to by the handle, with all HTML and PHP code striped. If an error occurs, returns FALSE.
Syntax
fgetss(file_path,length,tags)
Parameters
file_pointer - The file pointer must be valid and must point to the file opened successfully by fopen() File or fsockopen() (not yet closed by fclose()).
length - Data length
Tags - Tags you do not want to delete.
Return
The fgetss() function returns a string of maximum length 1 byte read from the file pointed to by the handle, in which all HTML and PHP code All are striped. If an error occurs, returns FALSE.
Suppose we have a "new.html" file with the following content. The Chinese translation of
<p><strong>Asia</strong> is a <em>continent</em>.</p>
Example
is:Example
<?php $file_pointer= fopen("new.html", "rw"); echo fgetss($file_pointer); fclose($file_pointer); ?>
The following is the output result. We didn't add parameters to avoid stripping HTML tags, so the output looks like this:
Output
Asia is a continent.
Now, let us see another example wherein we have the same file, but we will add the length and HTML tags parameters to avoid stripping of those tags. The Chinese translation of
Example
is:Example
<?php $file_pointer = @fopen("new.html", "r"); if ($file_pointer) { while (!feof($handle)) { $buffer = fgetss($file_pointer, 1024"<p>,<strong>,<em>"); echo $buffer; } fclose($file_pointer); } ?>
Output
Asia is a continent.
The above is the detailed content of fgetss() function in PHP. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c
