473,624 Members | 2,238 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1823
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_st art 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
8582
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, might as well move to PHP (for a variety of reasons - not trying to reopen the PHP -vs- CFM thing again :). Anyway, so I'm looking at this system, and there are no "scheduled tasks" (it's win2kas). How do you write a server app that needs to...
2
6753
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 Python 2.3.1 and GCC 3.2.3 (both installed by default with Slackware) and SWIG 1.3.19, compiled from source code. I messed around a little on my own and couldn't get things to work right, so I copied the examples from the book, nearly verbatim but...
0
2752
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 Traceback (most recent call last): File "<pyshell#0>", line 1, in -toplevel-
32
4631
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 where the loop will be traversed a fixed number of times. It is very flexible, and novice programmers should take care not to abuse the power it offers."
4
2712
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 source of the files...
77
3994
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 goto sometimes makes program some more cleaner and easy to understand and also quite useful (in error handling cases). So why goto is outlawed from civilized c programmers community. is there any technical inefficiency in that.
11
2437
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"> ..historylinks {
1
1847
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 testd_id="TESTD_ID_id0x03cc1988" testd_on_load="testdOnChange(testdGetElementById('TESTD_ID_id0x03cc1988'));" />
1
2629
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 and found that it is usually the result of faulty pointers or memory that is not allocated. However I have allocated all of my memory corectly (I feel) and my pointers look to be correct.. Is there another reason my code could be causing this error?...
0
8233
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8170
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8675
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7158
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4078
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2604
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1784
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1482
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.