English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

Usage and Example of PHP fgetss() Function

PHP Filesystem Reference Manual

The fgetss() function can return a line from the opened file, filtered out of HTML and PHP tags. This function can stop returning a new line of specified length or EOF (whichever comes first), and returns False on failure.

Syntax

string fgetss ( resource $handle [, int $length [, string $allowable_tags ] ] )

This function is similar to the fgets() function, the difference being that the fgetss() function can attempt to filter out all HTML and PHP tags from the read text.

Example1

<?php
   $handle = @fopen("/PhpProject/test.php", "r");
   if ($handle) {
      while (!feof($handle)) {
         $buffer = fgetss($handle, 4096);
         echo $buffer;
      }
      fclose($handle);
   }
?>

Output Result

Welcome to oldtoolbag.com

Example2

<?php
   $handle = @fopen("/PhpProject/test.php", "r");
   if ($handle) {
      while (!feof($handle)) {
         $buffer = fgetss($handle, 4096, ", ");
         echo $buffer;
      }
      fclose($handle);
   }
?>

PHP Filesystem Reference Manual