PHP code for executing a page _ PHP Tutorial

Source: Internet
Author: User
PHP executes time code on a page. Copy the code as follows :? PhpclassTimer page execution time class {varstarttime; page start execution time varstoptime; page end execution time varspendtime; page execution cost The code is as follows:


Class Timer // page execution time class
{
Var starttime; // the execution time of the page.
Var stoptime; // page end execution time
Var spendtime; // Time elapsed for page execution
Function getmicrotime () // gets the floating point number of the current microsecond.
{
List (usec, sec) = explode ("", microtime ());
Return (float) usec + (float) sec );
}
Function start () // start the execution of the function on the page, and return the execution time of the start page.
{
This-> starttime = this-> getmicrotime ();
}
Function display () // display the page execution time
{
This-> stoptime = this-> getmicrotime ();
This-> spendtime = this-> stoptime-this-> starttime;
Return round (this-> spendtime, 10 );
}
}
/* Call method
Timer = new Timer ();
Timer-> start ();
/* Put the script or code you want to execute here
For (I = 0; I <100000; I ++)
{
Echo I;
Echo"
";
}
*/
// Echo"

It takes time to execute the code ". timer-> display ()." second ";
?>

The http://www.bkjia.com/PHPjc/321374.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/321374.htmlTechArticle code is as follows :? Php class Timer // page execution time class {var starttime; // page start execution time var stoptime; // page end execution time var spendtime; // page execution cost...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.