function track_times() { static $i = 0; $i++; static $i = 5; return $i; } echo track_times() . "\n"; echo track_times() . "\n";
Result:
6 7
I know that people do not use static variables in this way, they simply cannot explain the result. The result implies that the second assignment takes effect, but $i increases to the destination, so why does the first function call return 6?
source share