I want to have a way where I can view the amount of times a script of PHP has been used? I want to have a file, that just has a number in it, then I want to be able to view this. So if 6 people send an email through my php script, then each time it is used it will add 1 to a number then save it to a file?
How could I do this?? Thanks.
You could use php's file_get_contents();
and file_put_contents();
functions:
$file = 'count.txt';
if(file_exists($file)){
$current = file_get_contents($file);
file_put_contents($file, ($current + 1));
}else
file_put_contents($file, 1);
//Define the name of the file
define('FILE_NAME', 'counter.txt');
//Check is there this file
if (file_exists(FILE_NAME)) {
//If yes, read out the content of it
$content = file(FILE_NAME);
//Put the incrased value
file_put_contents(FILE_NAME, $content[0] + 1);
} else {
//Create the file with 1 visitor
file_put_contents(FILE_NAME, 1);
}