File counter adds 2 instead of 1

Posted by Derk on Stack Overflow See other posts from Stack Overflow or by Derk
Published on 2010-03-30T13:24:27Z Indexed on 2010/03/30 13:33 UTC
Read the original article Hit count: 508

Filed under:
|
|
|

I made a simple counter, but it increments by 2 instead of 1.

    $handle = fopen('progress.txt', 'r');
    $pro = fgets($handle);
    print $pro; // incremented by 2, WTF?
    fclose($handle);

    $handle = fopen('progress.txt', 'w');
    fwrite($handle, $pro);
    fclose($handle);

Everytime I read the file it has been incremented by 2, instead of 1.

© Stack Overflow or respective owner

Related posts about php

Related posts about counter