define as follows
class Timer{
private static $timeRemaining;
private static $timeLimit;
private static $nextTime;
static function block();
static function updateCookies();
}
when going around between webpages, how long do those static properties and methods live? As a result, which one is better, using the class above or a singleton object?
They live as much as PHP executes a code - while request lives.
And of course, between webpages all data is erased. But you can use session and manually assign data to static variables or non-static instance variables.
Singletons use a static variable as a storage of instance.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.