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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.