Extension Cleanup

php.internals

Chris Cranford

21 years ago
Is there a set of functions within an extension that is called automatically by the ZEND engine framework to "initialize" and "deinitailize" the extension? In a particular PHP script, a user may call a method that sets up an environment. I cannot always rely on the user to call the cleanup API method at the end of the script. In that event, I would like my extension to automatically cleanup after itself when the script completes. Is there anyway to do this?

Sara Golemon

21 years ago
> Is there a set of functions within an extension that is called > automatically > by the ZEND engine framework to "initialize" and "deinitailize" the > extension? >
MINIT: Module Initialization (Called once when the PHP processor is started) RINIT: Request Initialization (Called at the start of every request) RSHUTDOWN: Request Shutdown (Called at the end of every request) MSHUTDOWN: Module Shutdown (Called when the PHP processor exits)
> In a particular PHP script, a user may call a method that sets up an > environment. I cannot always rely on the user to call the cleanup API > method at the end of the script. In that event, I would like my extension > to automatically cleanup after itself when the script completes. >
Resource dtors are also good for that kinda thing. -Sara