简体   繁体   中英

PHP background process similar to Nodejs

I suspect my question is rather rudimentary, but here it goes: In Node.js I can start a process and have it run in the background waiting for requests. For example, I can create a variable and increment it by 1 every time I get a request. How can I do the same in PHP? From what I understand PHP code is run just for the request, then everything is removed from memory. Thank you!

PHP is just a programming language, similar to JavaScript.

Node.js is an application server that is capable of running JavaScript applications, and allows you to listen to requests etc. as you described.

To achieve the same functionality with PHP, you will also need an application server. You could look into eg the Apache Web Server or Nginx .

Yes you can create a server process with PHP. For example applications created using the Symfony framework benefit from using a console script to launch a Web server for development purposes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM