473,394 Members | 1,887 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Coding "init" functiosn for an extension...

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
2 1817
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
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Greg Bryant | last post by:
I'm doing some work for a company that has an auction site running in coldfusion. They're not real happy with it, and it needs a major overhaul, so I'm looking at redoing it, and while I'm at it,...
2
by: Chris Hodapp | last post by:
I have seen messages posted about this before, and there is a clear reference to it in the manual, but I have been unable to find a solution. I'm on Slackware 9.1, kernel 2.6.0-test11, using...
0
by: Bill Davy | last post by:
Hello, I am using SWIG-1.3.24 to make an extension (called SHIP) to Python2.4.1 and then running under IDLE (if that makes any difference) but when I "import SHIP" I get: >>> import SHIP ...
32
by: Toby Newman | last post by:
At the page: http://www.strath.ac.uk/IT/Docs/Ccourse/subsection3_8_3.html#SECTION0008300000000000000 or http://tinyurl.com/4ptzs the author warns: "The for loop is frequently used, usually...
4
by: Don Wash | last post by:
Hi All! I'm getting the following Error: No DLLs has been compiled yet and nothing in the \bin directory. So it is not the versioning problem or anything like that. And here are the...
77
by: M.B | last post by:
Guys, Need some of your opinion on an oft beaten track We have an option of using "goto" in C language, but most testbooks (even K&R) advice against use of it. My personal experience was that...
11
by: jesdynf | last post by:
I'm having trouble applying a stylesheet to content I'm generating after the fact. Here's the sample code: <html> <head> <title>CSS/DOM Problem Example</title> <style type="text/css">...
1
by: C.W.Holeman II | last post by:
The init() is able to use the parameter passed to it in this example: <body onload="init(this);"> testdOnChange() in this example uses a more complicated technique: <testd:test...
1
by: Dameon99 | last post by:
Hi, I have just spent many hours debugging my code and now when I run it I get the following error: "An access violation (Segmentation fault) raised in your program" I have researched on this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.