"
" won't make new line in file

Hi this is a simple counter program.
[code]
counter2.php

<?php

$file = fopen("counter2.txt", "a+");

$counter=0;

while(!feof($file)) //Loops as long as file-pointer is not at end of file
{
fgets($file); //Moves file-pointer exactly one line
$counter++;
}

fwrite($file,$counter."
"); //<<<<---HERES THE PROBLEM

echo $counter;

fclose($file);

?>
[/code]
When I open the counter2.txt in notepad it should look like this:
1
2
3
4
5

Currently it looks like this:
?????

Looks like somekind of unicode error but fget() still interpret it as newline.

Thanks for your help.

Comments

  • Hi,

    On Windows, newlines are actually
    , not just
    .

    Jonathan
    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
  • : Hi,
    :
    : On Windows, newlines are actually
    , not just
    .
    :
    : Jonathan
    : ###
    : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    Wonderful thanks! Worked like a charm.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories