وظيفة PHP fgets ()
❮ مرجع نظام ملفات PHPمثال
اقرأ سطرًا واحدًا من الملف المفتوح:
<?php
$file = fopen("test.txt","r");
echo fgets($file);
fclose($file);
?>
التعريف والاستخدام
ترجع الدالة fgets () سطرًا من ملف مفتوح.
بناء الجملة
fgets(file, length)
قيمه المعامل
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 |
تفاصيل تقنية
قيمة الإرجاع: | قراءة سطر واحد من الملف عند النجاح أو FALSE في EOF أو الخطأ |
---|---|
إصدار PHP: | 4.0+ |
ثنائي آمن: | نعم ، في PHP 4.3 |
مزيد من الأمثلة
مثال
قراءة ملف مفتوح ، سطرًا بسطر:
<?php
$file = fopen("test.txt","r");
while(! feof($file))
{
echo fgets($file). "<br />";
}
fclose($file);
?>
❮ مرجع نظام ملفات PHP