Just use fopen, fgets, fwrite, and fclose.
<?PHP
/ Open File for Reading, read the file in
to the var $num_i, and the close the file /
$fp = fopen("File.txt", "r");
$num_i = fread($fp, 255);
fclose($fp);
/ Increment or modify var $num_i here /
$num_i++;
/ Open the file and write the modified number back to the
file and close the file /
$fp = fopen("File.txt", "w");
fwrite($fp, $num_i);
fclose($fp);
?>