我必须承认我是 PHP 的新手,但请看一下:
if(!isset($_SESSION['mailtime'])){
$_SESSION['mailtime'] = time();
echo 'Mail time: '. $_SESSION['mailtime'] .'</br>Time now: ' . time() . '</br>';
echo 'Since last mail:' . time()-($_SESSION['mailtime']) . ' sec';
}
else{
echo 'Mail time: '. $_SESSION['mailtime'] .'</br>Time now: ' . time() . '</br>';
echo 'Since last mail:' . time()-($_SESSION['mailtime']) . ' sec';
}
这给了我一个结果,例如:
Mail time: 10
Time now: 16
Since last mail: -10 sec
我的代码有什么问题?我试着做
$mailtime = $_SESSION['mailtime'];
但我得到较短的变量:
Mail time:
Time now:
Since last mail: 0 sec