13:34
Static variables inside functions are very interesting
I only just realised you don't need to ??=
assign to them for them to work that way. Actually, I found it frustrating that you can't declare and assign to them that way on the same line using ??=
, until I realised plain assign =
works the same way in this context
But what about generator functions? i.e. combining static $foo
and yield
. Each time the function is executed, it will create a new generator. So does it also allocate new memory for the "static" variable, or is it still shared?