PHP fgets() Funksie
❮ PHP-lêerstelselverwysingVoorbeeld
Lees een reël uit die oop lêer:
<?php
$file = fopen("test.txt","r");
echo fgets($file);
fclose($file);
?>
Definisie en gebruik
Die fgets() funksie gee 'n reël terug vanaf 'n oop lêer.
Sintaksis
fgets(file, length)
Parameterwaardes
Parameter | Description |
---|---|
file | Required. Specifies the open file to return a line from |
length | Optional. Specifies the number of bytes to read. Reading stops when length-1 bytes have been reached, or when a new line occurs, or on EOF. If no length is specified, it reads until end of the line |
Tegniese besonderhede
Terugkeerwaarde: | 'n Enkele reël gelees uit die lêer op sukses, ONWAAR op EOF of fout |
---|---|
PHP weergawe: | 4,0+ |
Binêre kluis: | Ja, in PHP 4.3 |
Meer voorbeelde
Voorbeeld
Lees oop lêer, reël vir reël:
<?php
$file = fopen("test.txt","r");
while(! feof($file))
{
echo fgets($file). "<br />";
}
fclose($file);
?>
❮ PHP-lêerstelselverwysing