Simple PHP Counter

//DECLARE YOUR COUNTER FILE
$counterFile="counter.txt";

//INCREMENT THE COUNTER
incrementCounter($counterFile);

//OUTPUT THE CURRENT COUNT
echo readCounter($counterFile);


function incrementCounter($counterFile)
{
$current=readCounter($counterFile);
$current++;

if(!$handle = fopen($counterFile, "w"))
{
return false;
}
else
{
if(fwrite($handle, $current) === FALSE)
{
return false;
}
}
fclose($handle);
return true;
}

function readCounter($counterFile)
{
$contents=file_get_contents($counterFile);
if(is_numeric((int)$contents))
{
return ((int)$contents);
}
else
{
return 0;
}
}
?>