#24627 [Bgs]: feof always returns false

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default #24627 [Bgs]: feof always returns false

    ID: 24627
    Updated by: [email]sniper@php.net[/email]
    Reported By: duerra at yahoo dot com
    Status: Bogus
    Bug Type: Filesystem function related
    Operating System: XP Pro
    PHP Version: 4.3.3RC1
    New Comment:

    Don't mix user added comments to real documentation..



    Previous Comments:
    ------------------------------------------------------------------------

    [2003-07-12 22:45:39] duerra at yahoo dot com

    Just a comment from the "feof" reference, as a basic point:

    if ($fp = fopen($filename, 'r'))
    {
    while (!feof($fp))
    {
    // ...
    }
    }

    That's exactly what I'm doing here (though the stating of the file
    pointer not moving is not explicitly stated, this is shown as working
    to a level that I have attempted to code...)

    ------------------------------------------------------------------------

    [2003-07-12 22:42:29] [email]sniper@php.net[/email]

    There must have been some bug in previous versions,
    feof() never moves the file pointer so you end up in endless loop, of
    course. (I don't know where in the manual it's said it moves the file
    pointer..)


    ------------------------------------------------------------------------

    [2003-07-12 22:39:43] duerra at yahoo dot com

    php.net's own manual shows that this should work. I'm not reading the
    file, but rather just gathering a count of each line. As I stated,
    this has always worked in previous versions of PHP, and is also many
    tutorials and books, including "PHP and MySQL Web Development" (as I am
    looking at the example right now) have shown an example almost
    identical to what I've posted here on how to do such looping and
    counting. I believe that the file pointer not moving is exactly the
    problem (please correct me if I'm wrong). Is that not a bug, and if
    not, what has changed between 4.3.2 and 4.3.3 that I have not noticed??
    I see nothing of reference in the change log for 4.3.3

    ------------------------------------------------------------------------

    [2003-07-12 18:31:30] duerra at yahoo dot com

    This always worked correct in previous versions of PHP. It wasn't
    until the move to 4.3.3RC1 (from 4.3.2) that I had this infinite
    looping problem.

    ------------------------------------------------------------------------

    [2003-07-12 18:28:42] [email]elmicha@php.net[/email]

    Thank you for taking the time to write to us, but this is not
    a bug. Please double-check the documentation available at
    [url]http://www.php.net/manual/[/url] and the instructions on how to report
    a bug at [url]http://bugs.php.net/how-to-report.php[/url]

    Yes, b_ulrich is right.

    ------------------------------------------------------------------------

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    [url]http://bugs.php.net/24627[/url]

    --
    Edit this bug report at [url]http://bugs.php.net/?id=24627&edit=1[/url]

    sniper@php.net Guest

  2. Similar Questions and Discussions

    1. mail() returns FALSE, no err msg
      Sometimes my mail() function returns FALSE, but there is no error message. Error reporting is set to E_ALL. It seems to be a problem of the bcc:...
    2. #24627 [Opn->Bgs]: feof always returns false
      ID: 24627 Updated by: elmicha@php.net Reported By: duerra at yahoo dot com -Status: Open +Status: ...
    3. #24627 [Bgs->Opn]: feof always returns false
      ID: 24627 User updated by: duerra at yahoo dot com Reported By: duerra at yahoo dot com -Status: Bogus +Status: ...
    4. #24627 [Com]: feof always returns false
      ID: 24627 Comment by: b_ulrich at t-online dot de Reported By: duerra at yahoo dot com Status: Open Bug Type: ...
    5. #24627 [NEW]: feof always returns false
      From: duerra at yahoo dot com Operating system: XP Pro PHP version: 4.3.3RC1 PHP Bug Type: Filesystem function related Bug...
  3. #2

    Default #24627 [Bgs]: feof always returns false

    ID: 24627
    Updated by: [email]sniper@php.net[/email]
    Reported By: duerra at yahoo dot com
    Status: Bogus
    Bug Type: Filesystem function related
    Operating System: XP Pro
    PHP Version: 4.3.3RC1
    New Comment:

    It has ALWAYS been the requirement. Some buffer sizes and so were
    adjusted in 4.3.2 (or something alike, can't remember exactly what it
    was right now) which made it LOOK like it worked for you.



    Previous Comments:
    ------------------------------------------------------------------------

    [2003-07-12 22:51:35] duerra at yahoo dot com

    Sorry. Here's from the documentation on "fgets()"

    $handle = fopen ("/tmp/inputfile.txt", "r");
    while (!feof ($handle)) {
    $buffer = fgets($handle, 4096);
    echo $buffer;
    }
    fclose ($handle);

    In essence, what was being done instead of the line beginning with
    "$buffer=", was "$count++". This this then a requirement now in 4.3.3
    that a line is actually retrieved for the file pointer to move? If so,
    I'll quit nagging you all =P

    ------------------------------------------------------------------------

    [2003-07-12 22:48:03] [email]sniper@php.net[/email]

    Don't mix user added comments to real documentation..


    ------------------------------------------------------------------------

    [2003-07-12 22:45:39] duerra at yahoo dot com

    Just a comment from the "feof" reference, as a basic point:

    if ($fp = fopen($filename, 'r'))
    {
    while (!feof($fp))
    {
    // ...
    }
    }

    That's exactly what I'm doing here (though the stating of the file
    pointer not moving is not explicitly stated, this is shown as working
    to a level that I have attempted to code...)

    ------------------------------------------------------------------------

    [2003-07-12 22:42:29] [email]sniper@php.net[/email]

    There must have been some bug in previous versions,
    feof() never moves the file pointer so you end up in endless loop, of
    course. (I don't know where in the manual it's said it moves the file
    pointer..)


    ------------------------------------------------------------------------

    [2003-07-12 22:39:43] duerra at yahoo dot com

    php.net's own manual shows that this should work. I'm not reading the
    file, but rather just gathering a count of each line. As I stated,
    this has always worked in previous versions of PHP, and is also many
    tutorials and books, including "PHP and MySQL Web Development" (as I am
    looking at the example right now) have shown an example almost
    identical to what I've posted here on how to do such looping and
    counting. I believe that the file pointer not moving is exactly the
    problem (please correct me if I'm wrong). Is that not a bug, and if
    not, what has changed between 4.3.2 and 4.3.3 that I have not noticed??
    I see nothing of reference in the change log for 4.3.3

    ------------------------------------------------------------------------

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    [url]http://bugs.php.net/24627[/url]

    --
    Edit this bug report at [url]http://bugs.php.net/?id=24627&edit=1[/url]

    sniper@php.net Guest

  4. #3

    Default #24627 [Bgs]: feof always returns false

    ID: 24627
    Updated by: [email]wez@php.net[/email]
    Reported By: duerra at yahoo dot com
    Status: Bogus
    Bug Type: Filesystem function related
    Operating System: XP Pro
    PHP Version: 4.3.3RC1
    New Comment:

    If you don't read from the pointer, the position never moves and thus
    never reaches the end of file.
    This current behaviour is the intended behaviour; if it worked before,
    it was a bug that you should consider fixed.



    Previous Comments:
    ------------------------------------------------------------------------

    [2003-07-12 22:54:35] [email]sniper@php.net[/email]

    It has ALWAYS been the requirement. Some buffer sizes and so were
    adjusted in 4.3.2 (or something alike, can't remember exactly what it
    was right now) which made it LOOK like it worked for you.


    ------------------------------------------------------------------------

    [2003-07-12 22:51:35] duerra at yahoo dot com

    Sorry. Here's from the documentation on "fgets()"

    $handle = fopen ("/tmp/inputfile.txt", "r");
    while (!feof ($handle)) {
    $buffer = fgets($handle, 4096);
    echo $buffer;
    }
    fclose ($handle);

    In essence, what was being done instead of the line beginning with
    "$buffer=", was "$count++". This this then a requirement now in 4.3.3
    that a line is actually retrieved for the file pointer to move? If so,
    I'll quit nagging you all =P

    ------------------------------------------------------------------------

    [2003-07-12 22:48:03] [email]sniper@php.net[/email]

    Don't mix user added comments to real documentation..


    ------------------------------------------------------------------------

    [2003-07-12 22:45:39] duerra at yahoo dot com

    Just a comment from the "feof" reference, as a basic point:

    if ($fp = fopen($filename, 'r'))
    {
    while (!feof($fp))
    {
    // ...
    }
    }

    That's exactly what I'm doing here (though the stating of the file
    pointer not moving is not explicitly stated, this is shown as working
    to a level that I have attempted to code...)

    ------------------------------------------------------------------------

    [2003-07-12 22:42:29] [email]sniper@php.net[/email]

    There must have been some bug in previous versions,
    feof() never moves the file pointer so you end up in endless loop, of
    course. (I don't know where in the manual it's said it moves the file
    pointer..)


    ------------------------------------------------------------------------

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    [url]http://bugs.php.net/24627[/url]

    --
    Edit this bug report at [url]http://bugs.php.net/?id=24627&edit=1[/url]

    wez@php.net Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139