Object Oriented PHP page counter?

shawneefemme

New member
For my php class, I am supposed to take a simple bit of code that the teacher created and turn it into an object oriented page counter. However, my teacher is poor at explaining objects in general, and I could really use some help

The perimeters of this assignment are:

-Create a page hit counter object that uses files to store the visit number and an to store details about the visit.
-Name the object "PageCounter" and place the code into a file named "PageCounter.php"
-When you create the new object pass the creator the "Page name"
-add a method called count() that will open the file "PAGENAME.count" read in the number increment it and write it back out.
-also have count add a line to "PAGENAME.log" that contains the date, time, $_SERVER["REMOTE_ADDR"],, and $_SERVER["REMOTE_HOST"] as a CSV so that you can see who has visited the site in detail.
-add a method called show() that will output a pretty <p></p> with the current page count.

And this is the code he provided:

<?php
$c = fopen("control.txt","r");
$num = fgets($c);
$num+=1;
fclose($c);
$c = fopen("control.txt","w");
fputs($c, $num);
fclose($c);

?>

Any and all assistance would be adored. Thank you all for your time.
 
Back
Top