0% found this document useful (0 votes)
342 views1 page

Write A PHP Program To Keep Track of The Number of Visitors Visiting The Web Page and To Display This Count of Visitors, With Proper Headings

This PHP program tracks the number of visitors to a web page by reading and writing to a text file called "count.txt" that stores the visit count. Each time the page is refreshed, it increments the count by 1, overwrites the new count in the text file, and displays the total number of views with a heading.

Uploaded by

Afreed Shahid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
342 views1 page

Write A PHP Program To Keep Track of The Number of Visitors Visiting The Web Page and To Display This Count of Visitors, With Proper Headings

This PHP program tracks the number of visitors to a web page by reading and writing to a text file called "count.txt" that stores the visit count. Each time the page is refreshed, it increments the count by 1, overwrites the new count in the text file, and displays the total number of views with a heading.

Uploaded by

Afreed Shahid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

6.

Write a PHP program to keep track of the number of visitors visiting the web page and to display
this count of visitors, with proper headings.

<?php
echo "<h3> REFRESH PAGE </h3>";
$name="count.txt";
$file=fopen($name, "r");
$hits=fscanf($file, "%d");
fclose($file);
$hits[0]++;
$file=fopen($name, "w");
fprintf($file, "%d", $hits[0]);
fclose($file);
echo "Total number of views:".$hits[0];
?>

You might also like