<?php
$filename = "count.txt";
$file = fopen( $filename, 'r' ); //We are only reading from the file this time, thus the r instead of w
$lines = file($filename);
/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Get's the data from the file. http://www.php.net/file. It seperates
the data into an array, which I will access in the next line.
*/
$count = $lines[0];
/* ^^^^^^^^^^^^^^^^^^^^^^^^
We are now getting the data from the array so we can use it in the script
*/
$c = ereg_replace('&counter=','',$count); // این تابع رو باید استفاده کنی تا مقدار متغیر قبلی رو بدست بیاری
$c++;
$count = "&counter=".$c;
echo $count;
// Adding one to the count, because we are counting each visit, and if this is loaded
// that means there is a new visitor to add :)
fclose( $file ); //Closing the file
$file = fopen($filename, "w" ); //Now we are gonna re-write the file with the new count of visitors
fwrite( $file, $count );
fclose( $file );
?>