PDA

View Full Version : PHP Page counter and page loadtime without MYSQL/MSSQL



ohnoyekoms
05-14-2012, 06:17 PM
For this you'll need two .php files, one called loadtime, and load show. once you create loadtime.php drop this snippet within it..


<?
$time = microtime();
$time = explode(" ", $time);
$time = $time[1] + $time[0];
$start = $time;

$count_my_page = ("views");
$hits = file($count_my_page);
$hits[0] ++;
$fp = fopen($count_my_page , "w");
fputs($fp , "$hits[0]");
fclose($fp);
?>


then you'll create loadshow.php which shows how long it took your server to load and process the page. so lets get to the snippet.

<?
$time = microtime(); $time = explode(" ", $time); $time = $time[1] + $time[0]; $finish = $time; $totaltime = ($finish - $start); printf ("<center><font color=white face=Verdana size=1>loaded in %f/ms. and $hits[0] views.</center>", $totaltime);
?>


so now we have the php files required for this. okay lets begin.

on the page you want to show a load time, at the top of the page, put <? include('loadtime.php'); ?> this will start the counter, it will also add a number to the page visit counter. then at the bottom right above your </html> put, <? include('loadshow.php'); ?> this will print out the load time.

and thats pretty much it. depending on where you put loadshow.php is where it quits the timer.

CloudStrife7x
05-14-2012, 06:22 PM
another great share bro :)

thegutta
05-14-2012, 06:31 PM
another great share bro :)

Yup another great share you got the right cloud but the thing is i have no idea what he's talking about lol but i guess some people will n they will love it whatever the is lol

ohnoyekoms
05-14-2012, 07:25 PM
thegutta, you can view a demo on the file hosting site, goto the main haven page, click the upload button on the right hand side, it'll load a page, goto the bottom and you'll see a load time and visits. thats my site running that exact code :P

thegutta
05-14-2012, 09:30 PM
thegutta, you can view a demo on the file hosting site, goto the main haven page, click the upload button on the right hand side, it'll load a page, goto the bottom and you'll see a load time and visits. thats my site running that exact code :P

Ohhhh lol yeah i see it i get it now lol great info ohnoyekoms thanks for speaking my language now :-D

ohnoyekoms
05-14-2012, 10:23 PM
you're welcome, live examples work better then explaining things :D