Or is everything reference counted with heap allocation? Since PHP has escape analysis, this could be used to use the stack instead, and kill the memory when the scope ends. If PHP uses the stack, can this be seen in the opcode?
This stackoverflow thread does not really answer my question. https://stackoverflow.com/questions/24223249/stack-and-heap-in-php#:~:text=In%20static%20typed%20languages%20all,known%20until%20the%20run%20time . Olle