/    Sign up×
Community /Pin to ProfileBookmark

sorry this is my first attempt at php so i figured id make a counter heres what i have so far:
<?php
$counter_file = “blah/counter.txt”;
if (!($fp = fopen($counter_file, “r”))) die (“Cannot Open $counter_file.”);
$counter = (int) fread($fp, 20);
fclose($fp);
$counter++;
echo “=$counter.”;
$fp = fopen($counter_file, “w”);
fwrite($fp, $counter);
fclose($fp);
?>
does that look right? also how do i implament this into my website do i just link it or what? thanks

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@akadisApr 22.2004 — you might want to check out [URL=http://forums.webdeveloper.com/showthread.php?s=&threadid=33122]this[/URL] thread...i had a similar question not a day or so ago.
Copy linkTweet thisAlerts:
@killmunchauthorApr 22.2004 — alright i see but how do you implement it into an html site say the files called counter.php how do i use it in index.html
×

Success!

Help @killmunch spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...