I don't understand how to use the second parameter when used with +. Trying to open a file, read one line of text and then write one line of text before closing the file. The example below, once I step passed the first fopen line, it already erased the content of the file, before I can even read it.
$fh = fopen("file.txt", "w+");
$line = (int) fgets($fh);
$line++;
fwrite($fh, $line);
fclose($fh);
I read the different fopen paremeter explanations, for example, comparing w and w+, they both state "start from the beginning of the file, and erase the content of the file", the only difference is that w+ also has "Open"???