$cntRes = fopen($cfile,"w+"); $countA = file($cfile); $countStr = $countA[0]; $count = (int)$countStr; $count++; echo $count; fwrite($cntRes,$count); fclose($cntRes);