How does the PHP runtime work?

4

I've always been interested in how long my code runs. The problem is that I do not quite understand how PHP code execution works. Below are the questions:

On the server, does the PHP code run on every request or is it always running?

If it is always up and running, does it create a new run for each new visitor?

If it's not always up and running, is there any way to keep it running? (even after the client has left the site)

On the internet I only found tutorials on language syntax and how to increase the execution time (which does not make sense if I do not know how it works).

    
asked by anonymous 19.02.2018 / 20:04

2 answers

3
  

On the server, does the php code run on every request or is it always up and running?

Yes, just like in any technology, it does not have something to do without running every time that activity is desired.

  

If it's always up and running, does it create a new run for every new visitor?

Who? Your code in PHP? No, it is only executed when it is necessary, nor could it be running without knowing what to do. It creates a new instance of execution each comes which is called, but there are optimizations for this.

  

If it's not always up and running, is there any way to keep it running? (even after the client left the site)

In PHP for web essentially has no way. Until it is possible, but it is wrong and it will bring problems, nor does it make sense to do this in PHP for web. If you need this it is better to choose another technology.

    
19.02.2018 / 20:30
0

If I understand your doubts well, PHP executes every request, when it is 'called' it creates a session that would be an open page in the browser, this session is active until the browser is open (or you can set the time that the session is opened by the php syntax) to each new visitor you can yes make it run a new session (again by php syntax) but goes much of your need ... Take a look at this site, it helps bales for who is starting it or in the middle level. link

    
19.02.2018 / 20:09