Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.47 KB | None | 0 0
  1. <?php
  2.     $percorso = "./contatore.txt";
  3.     $file = fopen($percorso, "r+");
  4.  
  5.     if($file == null){
  6.         touch($percorso);
  7.         $file = fopen($percorso, "r+");
  8.         fwrite($file, "1");
  9.     }
  10.     else{
  11.         $contatore = intval(file_get_contents($percorso)); //converto in int il contenuto del file
  12.         $contatore += 1;
  13.         fwrite($file, $contatore);
  14.         fclose($file);
  15.     }
  16.  
  17.     echo("<h1> Views: " . file_get_contents($percorso) . "<h1>")
  18. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement