, an array that is explicitly declared in the top-level scope is not called in the callback function of the OnMessage event, and each time a new array is reused and then manipulated, I tried the global keyword, and the use of the variable preceded by the & reference symbol does not work, What's the deal?
Reply content:
, an array that is explicitly declared in the top-level scope is not called in the callback function of the OnMessage event, and each time a new array is reused and then manipulated, I tried the global keyword, and the use of the variable preceded by the & reference symbol does not work, What's the deal?
My understanding is that $server->on is called when the client sends the message. This means that the server will restart a process to process the business logic.
So, you define what global,use or whatever is not valid.
This is called process isolation. In fact Swoole official documents have said.