Tuesday, 9 June 2020

page views count

page views count
how many times the page is opened
count.php
<?php
$fname = 'count.txt';
normal name is creaated and assigned
$fsize = filesize ($fname);
using this file function file created and get the size
$file = fopen($fname, 'r');
open the file and ready to read
$current = fread($file, $fsize)
read the file upto mention isze
fclose($file);
close the file
$current_inc = $current+1;
upto zero is there in current, incrimet that
$file = fopen($fname, 'w');
opent he file and ready to write
fwrite($file, $current-inc);
write the data to file
echo 'page hits: '. $current_inc.'</h2>';
so we priinted how manytimes open, that many times we write
?>
count.txt
if it is opened , what we entered, that’s only its display
index.php
<?php
include 'count.php';
?>

hwo to print how many hits are tehre ?
how to know how much data is there filesize
how to open the file and ready wto write fopen with read
how to read the file upto mentioned size fread
how to close the file fclose
how to incrimet the data inside the file
how to open the file and ready to write fopen with w
how to write into file fwrite
print the how many counts



No comments:

Post a Comment