2 ms·
"Sorry No" as in "PHP is a stupid language, stay away!" Which is a point I won't argue. Or in the "PHP has no destructors"? - in that: PHP's object model is an
by johannes1234321 6y ago
"Sorry No" as in "PHP is a stupid language, stay away!" Which is a point I won't argue.
Or in the "PHP has no destructors"? - in that: PHP's object model is an "interesting" mixture of Java and C++. In regards to C++ it has detemrinsitric destructors, which enable RAII. The only complication is that all objects are reference counted (like shared_ptr in C++) and one can easily lose ownership from where one expects it to be. However if you keep an eye on ownership you can rely on reference count being decreased on function exit (be it regular exit or exception) and the destructor being called, in LIFO order as one expects. This isn't used much in PHP as you don't have to manage resources as often as with other languages/domains (in short lived request world one doesn't care whether a database connection is destroyed on function end or only on request shutdown, memory is handled automatically, etc.)