I have file called denem.txt and has content
123456789
123456789
123456789
When we open a file with mode 'a+b' PHP is supposed to place the pointer to end of the file which means when I try to get a character with fgetc function it should return False since feof is true. However when I use a code something like
while (false !== ($char = fgetc($file))) {
echo "$char\n";
}
I get 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 . -> that is strange because I haven't used rewind() and pointer must be at the end of the file means fgetc must return a False. ftell returns int 0 means pointer is at the begining of the file. However when I try to write something to the file with fwrite which uses pointer's current position it supposed to write it to the begining of the file if ftell doesn't lie to us. But when I use fwrite guess what happens, it writes it to the end of the file and my file becomes
123456789
123456789
123456789Test
Do you have any idea about this?