page load timer class

usage: $page_timer = new page_timer; // at the start of your code echo $page_timer->end(); // at the end of your code.

PHP

class page_timer {
	public $start_time;
	public $load_time;
    function __construct() {
    	$this->start();
    }
	public function start() {
		$time = microtime();
		$time = explode(' ', $time);
		$time = $time[1] + $time[0];
		$this->start_time = $time;		
	}
	public function end() {
		$time = microtime();
		$time = explode(' ', $time);
		$time = $time[1] + $time[0];
		$finish = $time;
		$this->load_time = round(($finish - $this->start_time), 4);
		return 'Load Time: '.$this->load_time.' sec';			
	}
}

Demo

Other Items in php
Page Views

This page has been viewed 57 times.

Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

❤👩‍💻🕹