Hi all,

I just have a question about how PHP works.

Say I have several classes that I call but don't unset() once I've finished with them, how long will the server hang onto that data. Is it completely dependant on the client connection to the server?

Similarly, I understand a little about PHP pools - does this create a new 'instance' of php to serve every client connection?

Current versions of PHP (5.x and later at least) use a time-based reference-counted garbage collector. IE, every so often any object with 0 references will be removed from memory. The class is irrelevant. A class may be an object, but it isn't an "object" in the sense of something instantiated for operational purposes. As for "instance" for each connection, it may create a thread. I'm not sure about that, but the php documentation covers this stuff in great detail. Check www.php.net for details. FWIW, I have had to, in the past, dig into and fix php source code bugs, but I never had to deal with its threading/process model.

PHP is basically a C program (some implementations in C++) from version 4 and above it is a compiled language. It takes your code and translates it to opcodes and then execute it (this something common in programming languages) . PHP doesn't save those opcodes by default and nor you have to make this step (there are now mechanism to cache those). How you run PHP is your own choice , for more than 15 years PHP supports multi threading. There is of course to run it through CGI, fastCgi , mod_php and many many more. How you run PHP has to do of how the PHP programs are executed. In reality you can start PHP and have each PHP program instantiator make its own thread. You wrote that you understand about PHP pools. I don't because it all depends of how you are running PHP. But if we are talking about PHP Pools (pthreads) this is a whole different issue.