/    Sign up×
Community /Pin to ProfileBookmark

Is it possible to make webcounters from PHP

I’ve used third-party webcounters for many years, but recently, the site has been experiencing difficulties, so I was wondering if it’s possible to create my own.

Yes, I use webcounters. The wisdom thereof is beside the point; it’s a personal page, so it’s allowed to suck. ?

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogOct 30.2013 — Should be simple. Just need to decide how/where you want to store the count, and whether or not you want to do any filtering, such as trying to not count search engine bots, etc.
Copy linkTweet thisAlerts:
@Mr_Initial_ManauthorNov 05.2013 — How would you set it up?
Copy linkTweet thisAlerts:
@NogDogNov 05.2013 — Something real simple (and untested):

First, create a file (I'll call it counter.txt for this example) with just one line with the value "0" (zero, no quotes).

Then on any page where you want to increment the count:
[code=php]
<?php
file_put_contents('counter.txt', trim(file_get_contents('counter.txt')) + 1);
?>
[/code]

Any place you want to output the current count:
[code=php]
<?php
echo trim(file_get_contents('counter.txt'));
?>
[/code]
×

Success!

Help @Mr_Initial_Man 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 5.3,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

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