Firstly we declare the filename variable to hold the location of the text file. This is pretty self explanatory.
$fd = fopen ($filename , "r") or die ("Can't open $filename") ;
Next, try to open the file declared above for read only access (that's what the r is for) or throw an error if it can't be opened.
$fstring = fread ($fd , filesize ($filename)) ;
Read the entire contents of the file (a number hopefully!) and store it in $fstring
Print out contents of the file.
Close the file for reading.
$fd = fopen ($filename , "w") or die ("Can't open $filename") ;
Open the file for writing or throw an error if it can't be opened.
$fcounted = $fstring + 1 ;
Declare a variable that's $fstring (the contents of the file previously) by one
$fout= fwrite ($fd , $fcounted ) ;
Write the new number to the file
Close the file for writing.
Make more sense now?