PHP fgetss() Function
In this chapter you will learn:
- Definition for PHP fgetss() Function
- Syntax for PHP fgetss() Function
- Parameter for PHP fgetss() Function
- Return for PHP fgetss() Function
- Example - Read a html file
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/* j a v a2s . c o m*/
$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.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP file() Function
- Syntax for PHP file() Function
- Parameter for PHP file() Function
- Return for PHP file() Function
- Example - Convert file to an array
- Example - Output a file as an array
Home » PHP Tutorial » PHP File Functions