« I Fixed the Formatting Problem | Main | Fixing the Hit Counter »
Friday, July 31, 2009I Posted My First php ProgramI posted my first php program today. It is just a simple hit counter for my web page: www.thekimerers.com/brian/I downloaded most of it from the net, but then I had to make a change in order to get it to work properly. Here is the complete file:
?php $file = 'counter.txt'; if(!file_exists($file)) { $handle = fopen($file, 'w'); fwrite($handle, 0); fclose($handle); } $count = file_get_contents($file); // Trim the newline of one is there $count = trim($count); $count++; if(is_writable($file)) { $handle = fopen($file, 'w+'); fwrite($handle, $count); fclose($handle); } else { echo 'Could not increment the counter! I had to change my index page from index.shtml to index.php to get it to work. What does this have to do with this blog? Some day I will probably change this blog from .html files to .php files and try to make it a bit smarter. Stay tuned.
Posted by Brian S. Kimerer at 11:20 PM
This site and all of its contents are copyright Brian S. Kimerer 2009 |
I am a software engineer by trade. For fun I build and play banjos and paint pictures. To see some of my work, click on the link that says "My Web Site" in the Links section of this page. Favorite Links
Google Site Search
Credits
|