PHP fgetss() Function

Definition

The fgetss() function returns a line, with HTML and PHP tags removed, from an open file.

Syntax

PHP fgetss() Function has the following syntax.

fgetss(file,length,tags)

Parameter

ParameterIs RequiredDescription
fileRequired.File to check
lengthOptional.Number of bytes to read. Default is 1024 bytes.
tagsOptional.Tags that will not be removed

Return

This function returns FALSE on failure.

Example


<?php//from w  w  w  . j a v a 2  s. c om
$str = <<<EOD
<html><body>
 <p>Welcome!.</p>
</body></html>
Text outside of the HTML block.
EOD;
file_put_contents('index.php', $str);

$handle = @fopen("index.php", "r");
if ($handle) {
    while (!feof($handle)) {
        $buffer = fgetss($handle, 1024);
        echo $buffer;
    }
    fclose($handle);
}
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions