计算不同页面php上的时间处理

时间:2016-07-23 07:43:29

标签: php timer

我在第一页尝试此代码

template<typename T>
class FooOwner {
private:
    Foo<T>* p;  // This can point to a object of type Foo<U>
                // where U is a subclass of T
};

// NOTE: Foo<Derived> is always a subclass of Foo<Base>

template<typename T>
class Foo {
private:
    template<typename U>  // Constrain U to be a superclass of T?
    friend class FooOwner;
};

和第二页中的此代码

$time_start = microtime(true);
$_SESSION['varname'] = $time_start;

但变量$ time_start未知 如何计算不同页面上的时间处理?

1 个答案:

答案 0 :(得分:0)

试试这个..

<强> test1.php

session_start();
$time_start = microtime(true);
$_SESSION['varname'] = $time_start;

<强> test2.php

session_start();
$time_start = $_SESSION['varname'];
$time_end = microtime(true);
$time = $time_end - $time_start;
echo 'Execution time : ' . $time . ' seconds';

<强>输出: 执行时间:77.626733064651秒