0

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?

3
Contributors
2
Replies
19
Views
1 Year
Discussion Span
Last Post by jkon
1

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.

Edited by rubberman

1

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.

Edited by jkon

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.