By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,908 Members | 2,056 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,908 IT Pros & Developers. It's quick & easy.

Coding "init" functiosn for an extension...

P: n/a
Another question about writing PHP 5 extensions. What's the difference in
PHP_MINIT() / PHP_MSHUTDOWN() and PHP_RINIT() / PHP_RSHUTDOWN()? When would
a "per request" init be made?
Thanks,
Lee
LeeStewart @ gmail.com
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Lee,

When you have all of those, there are ones that they call when the
extension is initialized and when shutdown. That is the simple explanation.
Now for the more explained description:

PHP_MINIT - Module Initialization.
This gives each extension a chance to initialize internal variables,
allocate resources, register resource handlers, and register its
functions with ZE, so that if a script calls one of those functions, ZE
knows which code to execute.

PHP_RINIT - Request Initialization.
RINIT gives the extension a chance to set up specific environment
variables, allocate request specific resources, or perform other tasks
such as auditing. A prime example of the RINIT function in action is in
the sessions extension where, if the session.auto_start option is
enabled, RINIT will automatically trigger the userspace session_start()
function and pre-populate the $_SESSION variable.

PHP_MSHUTDOWN - Module Shutdown.
During shutdown of php it calls all of the PHP_MSHUTDOWN functions and
then shuts down its core subsystems.

PHP_RSHUTDOWN - Request Shutdown
This allows you to preform all the last minute cleanup on the extension
and save anything that you might need to save.

Hope that helps...
All of this is explained in the zend extension tutorials..
http://www.zend.com/php/internals/ex...n-writing1.php
http://www.zend.com/php/internals/ex...n-writing2.php

Mike
Another question about writing PHP 5 extensions. What's the difference in
PHP_MINIT() / PHP_MSHUTDOWN() and PHP_RINIT() / PHP_RSHUTDOWN()? When would
a "per request" init be made?
Thanks,
Lee
LeeStewart @ gmail.com

Jul 17 '05 #2

P: n/a
> All of this is explained in the zend extension tutorials..
http://www.zend.com/php/internals/ex...n-writing1.php
http://www.zend.com/php/internals/ex...n-writing2.php


I was using existing extensions to get details on how to implement one of
these - thanks for the pointer to the docs! The "lifecycle" is especially
useful for me, since I need to be careful when I initialize and free data.
Thanks!
Lee
LeeStewart @ gmail.com
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.