Please notice that I am attepting to call a function "hitCounterPosition()"
in the constructor "Counter" with this line of code:
$this->mCountPosition = $this->hitCounterPosition();
The very next line in the code prints out the value of mCountPosition
printf(">>>" . $this->mCountPosition . "<<< <BR>");
The output is not what I expected. I am expecting:
Instead I am getting:
"Eric Starr" <[EMAIL PROTECTED]> wrote in message
003f01c1d748$8785e200$[EMAIL PROTECTED]">news:003f01c1d748$8785e200$[EMAIL PROTECTED]...
I am learning PHP and I am having some trouble. I am working on a hit
counter application. I am using PHP 4 even though the file extension might
lead you to believe I am using PHP 3.
This code is on a page called "homePage.php3". Here is the instantiation of
$counter = new Counter("homePage.php3");
echo "<BR>All Done!"
Here is count.txt... this is where I store the counts of each page...this is
some test data:
Here is my counter.php3 code. This code is not complete. All it should do
right now is to output the position in the array that it found the
hitcounter...using the test data above I am expecting the output to be
">>>1<<<", assuming that PHP arrays are zero numbered, but instead I am
getting ">>><<<". What am I doing wrong?
var $mName; // The name of the counter...this should be the name of the web
page the counter is on
var $mCount; // The C
var $mCountPosition; //this is the position of the counter in mFileArray
$this->mDataFile = "./counter/count.txt";
$this->mCount = 1;
$this->mCounterPosition = -1;
$this->mName = $name;
$this->mHandle = fopen($this->mDataFile, "r+");
// Reading the file into an array...each new line is a seperate element
of the array
if (!($this->mFileArray = file($this->mDataFile)))
printf("Could not read this file: " . $mHandle . "<BR>");
$this->mCountPosition = $this->hitCounterPosition(); // ??? Why is
this not returning anything ???
printf(">>>" . $this->mCountPosition . "<<< <BR>"); // The output I am
getting is: >>><<<
function hitCounterPosition() //returns the position of the hitcounter in
for ($i=0; $i < count( $mFileArray ); $i++) // iterates through the array
$pos = strpos( $mFileArray[$i], $mName);
if (!is_integer($pos)) // The hit counter has NOT been found
else // The hit counter has been found
} // end of class
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php