Testing reply...
************** "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 my Counter: <?php include('./counter/counter.php3'); $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: testPage.php3 6 homePage.php3 76 b 99 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? <?php class Counter { 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 $mDataFile; var $mHandle; var $mFileArray; var $mCountPosition; //this is the position of the counter in mFileArray // Constructor function Counter($name) { $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 mFileArray { 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 { return (-1); } else // The hit counter has been found { return ($pos); } } } } // end of class ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php