downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

SplFileObject::fgetss> <SplFileObject::fgetcsv
[edit] Last updated: Fri, 24 Jun 2011

view this page in

SplFileObject::fgets

(PHP 5 >= 5.1.0)

SplFileObject::fgetsدریافت خطا از فایل

Description

public string SplFileObject::fgets ( void )

دریافت خط از فایل.

Parameters

This function has no parameters.

Return Values

بازگرداندن رشته شامل خط بعدی فایل یا در صورت خطا FALSE.

Errors/Exceptions

ایحاد RuntimeException اگر فایل نمی‌تواند خوانده شود.

Examples

Example #1 مثال SplFileObject::fgets()

این مثال بسادگی محتوای file.txt را خط به خط به خروجی می‌فرستد.

<?php
$file 
= new SplFileObject("file.txt");
while (!
$file->eof()) {
    echo 
$file->fgets();
}
?>

See Also



add a note add a note User Contributed Notes SplFileObject::fgets - [1 notes]
up
0
Anonymous
22 days ago
fgets don't skip empty lines if SplFileObject::SKIP_EMPTY is enabled.

Instead use

<?php
 
while (!$file->eof()) {
   
$file->next();
    echo
$file->current();
  }
?>

 
show source | credits | stats | sitemap | contact | advertising | mirror sites