Jump to content

hit counter -object oriented


seadonkey

Recommended Posts

This is just a front end very basic hit counter I am working on

 

<?php

class HitCounter

{

/* $fileName - the name of the text file that contains the current number of hits.*/

private $fileName = "";

/*

This construct holds the text file that contains the number of hits*/

function __construct($file)

{

$this->fileName = $file;

 

}

/*reads the contents of the text file specified in $fileName and returns the value*/

public function getCounter()

{

$newValue = $this.getCounter();

    $newValue++;

 

 

}

/*this will add the number to the file */

public function setCounter($counter)

{

file_put_contents($fileName, $counter);

}

 

/*This will get the current counter numbe rand will updated it for each new hit it

 

gets. */

public function updateCounter()

{

$this->getCounter();

$this->setCounter($newValue);

}

 

}

 

 

?>

 

When I try to run it I am getting Fatal error: Call to undefined function getcounter() in /home/academyw/public_html/rudolph/lab12/HitCounterClass.php on line 16

and was wondering if you could point me in the right direction or see what I am doing wrong.

Link to comment
https://forums.phpfreaks.com/topic/102027-hit-counter-object-oriented/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.