Vali79 Vali79 - 1 year ago 124
Javascript Question

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!

Answer Source

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 e.g. the Apache Web Server or Nginx.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download