Why can't the global array be used in swoole's event callback function?

WBOY
Release: 2016-08-18 09:16:26
Original
1278 people have browsed it

Why can't the global array be used in swoole's event callback function?

Why can't the global array be used in swoole's event callback function?

As shown in the figure, the array explicitly declared in the top-level scope cannot be called in the callback function of the onmessage event. Each time, a new array is reused and then operated. I have tried the global keyword and it does not work. It works, and adding the & reference symbol in front of the variable in use also doesn't work. What should I do?

Reply content:

Why can't the global array be used in swoole's event callback function?

Why can't the global array be used in swoole's event callback function?

As shown in the figure, the array explicitly declared in the top-level scope cannot be called in the callback function of the onmessage event. Each time, a new array is reused and then operated. I have tried the global keyword and it does not work. It works, and adding the & reference symbol in front of the variable in use also doesn't work. What should I do?

My understanding is that $server->on is called when the client sends information. In other words, the server will restart a process to handle the business logic.
So, whatever global and use you define are invalid.

This is called process isolation. In fact, swoole official documentation says it.

Why can't the global array be used in swoole's event callback function?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!