class script_timer
{
var $_construct;
function script_timer ($_x = 1)
{
$this->_construct = $_x;
return true;
}
function start_timer ()
{
@define ("TIMER_START_TIME", microtime());
return true;
}
function get_time ($decimals=2)
{
$start_time = explode (" ", TIMER_START_TIME);
$start_time = $start_time[1] + $start_time[0];
$end_time = explode (" ", microtime());
$end_time = $end_time[1] + $end_time[0];
if ($this->_construct) {
return '<br><br>'.(number_format ($end_time - $start_time, $decimals));
} else {
return null;
}
}
}
$timer = new script_timer(1);
$timer->start_timer();
$timer->get_time();
//kods
$timer->get_time();
merijam "//kods" ieksha php izpildes rezultatu milisekundes