PHP fgets() İşlevi
❮ PHP Dosya Sistemi ReferansıÖrnek
Açık dosyadan bir satır okuyun:
<?php
$file = fopen("test.txt","r");
echo fgets($file);
fclose($file);
?>
Tanım ve Kullanım
fgets() işlevi, açık bir dosyadan bir satır döndürür.
Sözdizimi
fgets(file, length)
Parametre Değerleri
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 |
Teknik detaylar
Geri dönüş değeri: | Başarı durumunda dosyadan okunan tek satır, EOF'de FALSE veya hata |
---|---|
PHP Sürümü: | 4.0+ |
İkili Kasa: | Evet, PHP 4.3'te |
Daha fazla örnek
Örnek
Açık dosyayı satır satır okuyun:
<?php
$file = fopen("test.txt","r");
while(! feof($file))
{
echo fgets($file). "<br />";
}
fclose($file);
?>
❮ PHP Dosya Sistemi Referansı