maanoo/blog

Friday, November 6, 2015

PHP: Simple counter

A simple counter using a text file.

The php code:

<?php
  $path = "./counter.txt";
  $count = intval(file_get_contents($path));
  if(isset($_GET["add"])) {
    $count++;
    file_put_contents($path, $count);
  }
  echo $count;
?>

To add one to the counter must be called with GET parameter add.

To get the counter value must be called with no parameters.


done_
Posted by Akritas Akritidis at 10:00 AM
Labels: code, php, utils
Newer Post Older Post Home

Search

Labels

code utils techniques java javascript life android build c easy make makefile c++ css enum html python windows bash email greek it is known php regex security

Blog Archive

  • ►  2021 (8)
    • ►  September (1)
    • ►  June (3)
    • ►  March (1)
    • ►  February (3)
  • ►  2020 (6)
    • ►  May (1)
    • ►  March (1)
    • ►  February (3)
    • ►  January (1)
  • ►  2019 (4)
    • ►  October (1)
    • ►  August (1)
    • ►  July (1)
    • ►  January (1)
  • ►  2018 (3)
    • ►  November (1)
    • ►  September (1)
    • ►  July (1)
  • ►  2017 (1)
    • ►  May (1)
  • ►  2016 (3)
    • ►  November (1)
    • ►  October (1)
    • ►  September (1)
  • ▼  2015 (12)
    • ▼  November (9)
      • Techniques: Random art with symmetry
      • Javascript: Canvas circles
      • HTML: Canvas background
      • Android: Store values
      • JavaScript: Local and Session storage
      • JavaScript: jQuery selector
      • PHP: Simple counter
      • CSS: Transition all
      • Techniques: Base64
    • ►  October (3)

Website

maanoo.com
Copyright © 2015 Akritas Akritidis. Simple theme. Powered by Blogger.