What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Tiny winy PHP question :P

Tiny winy PHP question :P
Author: Message:
hmaster
Senior Member
****

Avatar

Posts: 716
Reputation: 24
33 / Male / Flag
Joined: Nov 2004
RE: Tiny winy PHP question :P
Heres a commented version of a 'hit logger'

code:
<?php
// Define the text file to store data
   $HitFile = "logger.txt";
// Open the file for reading and writing
   $handle = fopen($HitFile, "r+");
// Lock the file for exclusive access (protects from data coruption)
   flock($handle, LOCK_EX);
// Get the contents of the file (the old hit count)
   $oldcount = fgets($handle);
// Increment 1 to the old count
   $newcount = $oldcount + 1;
// Set the file head to the begining (destroys the old data)
   rewind($handle);
// Write the new count to the file
   fwrite($handle, $newcount);
// Unlock the file
   flock($handle, LOCK_UN);
// Close the file
   fclose($handle);
// Display the new hit count
echo $newcount;
?>

logger.txt should have 0 to begin with :)
[Image: sig.png]
03-20-2006 09:00 PM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Tiny winy PHP question :P - by ayjay on 03-19-2006 at 03:34 PM
RE: Tiny winy PHP question :P - by Josh Loughlin on 03-19-2006 at 03:52 PM
RE: Tiny winy PHP question :P - by absorbation on 03-19-2006 at 03:53 PM
RE: Tiny winy PHP question :P - by RaceProUK on 03-19-2006 at 04:02 PM
RE: Tiny winy PHP question :P - by J-Thread on 03-19-2006 at 04:07 PM
RE: Tiny winy PHP question :P - by ayjay on 03-19-2006 at 04:41 PM
RE: Tiny winy PHP question :P - by WDZ on 03-20-2006 at 05:18 AM
RE: Tiny winy PHP question :P - by ayjay on 03-20-2006 at 08:23 PM
RE: Tiny winy PHP question :P - by hmaster on 03-20-2006 at 09:00 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On