PHP fseek() İşlevi
❮ PHP Dosya Sistemi ReferansıÖrnek
Açık dosyadan ilk satırı okuyun, ardından dosya işaretçisini dosyanın başına geri taşıyın:
<?php
$file = fopen("test.txt","r");
// Read first line
echo fgets($file);
// Move back to beginning of file
fseek($file,0);
fclose($file);
?>
Tanım ve Kullanım
fseek() işlevi açık bir dosyada arama yapar.
Bu işlev, dosya işaretçisini geçerli konumundan, bayt sayısıyla belirtilen ileri veya geri yeni bir konuma taşır.
İpucu: Geçerli konumu ftell() kullanarak bulabilirsiniz!
Sözdizimi
fseek(file, offset, whence)
Parametre Değerleri
Parameter | Description |
---|---|
file | Required. Specifies the open file to seek in |
offset | Required. Specifies the new position (measured in bytes from the beginning of the file) |
whence | Optional. Possible values:
|
Teknik detaylar
Geri dönüş değeri: | Başarıda 0, aksi takdirde -1 |
---|---|
PHP Sürümü: | 4.0+ |
❮ PHP Dosya Sistemi Referansı