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
Parameter | Is Required | Description |
---|---|---|
file | Required. | File to check |
length | Optional. | Number of bytes to read. Default is 1024 bytes. |
tags | Optional. | 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.