This seems simple but I can\'t figure it out.
file_get_contents(\'count.txt\');
$variable_from_file++;
file_put_contents(\'count.txt\', $variable_from_file);
Exactly like you did it should work fine. Just capture the data from file_get_contents(), and check if both of those functions were successful.
$var = file_get_contents('count.txt');
if ($var === false) {
die('Some error message.');
}
$var++;
if (file_put_contents('count.txt', $var) === false) {
die('Some error message.');
}