📄 internals2.structure.modstruct.html
字号:
<td colspan="1" rowspan="1" align="left"><b><tt>NO_VERSION_YET</tt></b></td> <td colspan="1" rowspan="1" align="left"> A string giving the version of the module, as specified by the module developer. It is recommended that the version number be either in the format expected by version_compare() (e.g. "1.0.5-dev"), or a CVS or SVN revision number (e.g. "$Rev$"). </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"> <var class="varname">globals_size</var> <a href="#fnidinternals2.structure.modstruct.struct-values.not-for-dev"><sup>[1]</sup></a> <a href="#fnidinternals2.structure.modstruct.struct-values.given-by-SMP" name="fninternals2.structure.modstruct.struct-values.given-by-SMP"><sup>[4]</sup></a> <a href="#fnidinternals2.structure.modstruct.struct-values.given-by-NMG" name="fninternals2.structure.modstruct.struct-values.given-by-NMG"><sup>[5]</sup></a> <a href="#fnidinternals2.structure.modstruct.struct-values.given-by-PMG" name="fninternals2.structure.modstruct.struct-values.given-by-PMG"><sup>[6]</sup></a> </td> <td colspan="1" rowspan="1" align="left">sizeof(zend_mymodule_globals)</td> <td colspan="1" rowspan="1" align="left"> The size of the data structure containing the module's globals, if any. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"> <var class="varname">globals_id_ptr</var> <a href="#fnidinternals2.structure.modstruct.struct-values.not-for-dev"><sup>[1]</sup></a> <a href="#fnidinternals2.structure.modstruct.struct-values.given-by-SMP"><sup>[4]</sup></a> <a href="#fnidinternals2.structure.modstruct.struct-values.given-by-NMG"><sup>[5]</sup></a> <a href="#fnidinternals2.structure.modstruct.struct-values.given-by-PMG"><sup>[6]</sup></a> <a href="#fnidinternals2.structure.modstruct.struct-values.only-with-ZTS" name="fninternals2.structure.modstruct.struct-values.only-with-ZTS"><sup>[7]</sup></a> </td> <td colspan="1" rowspan="1" align="left">&mymodule_globals_id</td> <td colspan="1" rowspan="2" align="left"> Only one of these two fields will exist, depending upon whether the <b><tt>USING_ZTS</tt></b> constant is <b><tt>TRUE</tt></b>. The former is an index into TSRM's allocation table for the module's globals, and the latter is a pointer directly to the globals. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"> <var class="varname">globals_ptr</var> <a href="#fnidinternals2.structure.modstruct.struct-values.not-for-dev"><sup>[1]</sup></a> <a href="#fnidinternals2.structure.modstruct.struct-values.given-by-SMP"><sup>[4]</sup></a> <a href="#fnidinternals2.structure.modstruct.struct-values.given-by-NMG"><sup>[5]</sup></a> <a href="#fnidinternals2.structure.modstruct.struct-values.given-by-PMG"><sup>[6]</sup></a> <a href="#fnidinternals2.structure.modstruct.struct-values.only-without-ZTS" name="fninternals2.structure.modstruct.struct-values.only-without-ZTS"><sup>[8]</sup></a> </td> <td colspan="1" rowspan="1" align="left">&mymodule_globals</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"> <var class="varname">globals_ctor</var> <a href="#fnidinternals2.structure.modstruct.struct-values.given-by-SMP"><sup>[4]</sup></a> <a href="#fnidinternals2.structure.modstruct.struct-values.given-by-NMG"><sup>[5]</sup></a> <a href="#fnidinternals2.structure.modstruct.struct-values.given-by-PMG"><sup>[6]</sup></a> </td> <td colspan="1" rowspan="1" align="left">PHP_GINIT(mymodule)</td> <td colspan="1" rowspan="1" align="left"> This funtion is called to initialize a module's globals <em class="emphasis">before</em> any <var class="varname">module_startup_func</var>. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"> <var class="varname">globals_dtor</var> <a href="#fnidinternals2.structure.modstruct.struct-values.given-by-SMP"><sup>[4]</sup></a> <a href="#fnidinternals2.structure.modstruct.struct-values.given-by-NMG"><sup>[5]</sup></a> <a href="#fnidinternals2.structure.modstruct.struct-values.given-by-PMG"><sup>[6]</sup></a> </td> <td colspan="1" rowspan="1" align="left">PHP_GSHUTDOWN(mymodule)</td> <td colspan="1" rowspan="1" align="left"> This funtion is called to deallocate a module's globals <em class="emphasis">after</em> any <var class="varname">module_shutdown_func</var>. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"> <var class="varname">post_deactivate_func</var> <a href="#fnidinternals2.structure.modstruct.struct-values.given-by-SMP"><sup>[4]</sup></a> </td> <td colspan="1" rowspan="1" align="left">ZEND_MODULE_POST_ZEND_DEACTIVATE_N(mymodule)</td> <td colspan="1" rowspan="1" align="left"> This function is called by Zend after request shutdown. It is rarely used. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"> <var class="varname">module_started</var> <a href="#fnidinternals2.structure.modstruct.struct-values.not-for-dev"><sup>[1]</sup></a> <a href="#fnidinternals2.structure.modstruct.struct-values.given-by-SMPE" name="fninternals2.structure.modstruct.struct-values.given-by-SMPE"><sup>[9]</sup></a> <a href="#fnidinternals2.structure.modstruct.struct-values.given-by-SMP"><sup>[4]</sup></a> </td> <td colspan="1" rowspan="1" align="left">0</td> <td colspan="1" rowspan="4" align="left"> These fields are used for Zend's internal tracking information. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"> <var class="varname">type</var> <a href="#fnidinternals2.structure.modstruct.struct-values.not-for-dev"><sup>[1]</sup></a> <a href="#fnidinternals2.structure.modstruct.struct-values.given-by-SMPE"><sup>[9]</sup></a> <a href="#fnidinternals2.structure.modstruct.struct-values.given-by-SMP"><sup>[4]</sup></a> </td> <td colspan="1" rowspan="1" align="left">0</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"> <var class="varname">handle</var> <a href="#fnidinternals2.structure.modstruct.struct-values.not-for-dev"><sup>[1]</sup></a> <a href="#fnidinternals2.structure.modstruct.struct-values.given-by-SMPE"><sup>[9]</sup></a> <a href="#fnidinternals2.structure.modstruct.struct-values.given-by-SMP"><sup>[4]</sup></a> </td> <td colspan="1" rowspan="1" align="left"><b><tt>NULL</tt></b></td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"> <var class="varname">module_number</var> <a href="#fnidinternals2.structure.modstruct.struct-values.not-for-dev"><sup>[1]</sup></a> <a href="#fnidinternals2.structure.modstruct.struct-values.given-by-SMPE"><sup>[9]</sup></a> <a href="#fnidinternals2.structure.modstruct.struct-values.given-by-SMP"><sup>[4]</sup></a> </td> <td colspan="1" rowspan="1" align="left">0</td> </tr> </tbody> </colgroup> <tbody valign="middle" class="footnote"><tr valign="middle"><td colspan="3" rowspan="1" align="left"><div class="footnote"><a name="fnidinternals2.structure.modstruct.struct-values.not-for-dev" href="#fninternals2.structure.modstruct.struct-values.not-for-dev"><sup>[1]</sup></a><span class="para footnote"> This field is not intended for use by module developers. </span></div><div class="footnote"><a name="fnidinternals2.structure.modstruct.struct-values.given-by-SMHE" href="#fninternals2.structure.modstruct.struct-values.given-by-SMHE"><sup>[2]</sup></a><span class="para footnote"> This field is filled in by <b><tt>STANDARD_MODULE_HEADER_EX</tt></b>. </span></div><div class="footnote"><a name="fnidinternals2.structure.modstruct.struct-values.given-by-SMH" href="#fninternals2.structure.modstruct.struct-values.given-by-SMH"><sup>[3]</sup></a><span class="para footnote"> This field is filled in by <b><tt>STANDARD_MODULE_HEADER</tt></b>. </span></div><div class="footnote"><a name="fnidinternals2.structure.modstruct.struct-values.given-by-SMP" href="#fninternals2.structure.modstruct.struct-values.given-by-SMP"><sup>[4]</sup></a><span class="para footnote"> This field is filled in by <b><tt>STANDARD_MODULE_PROPERTIES</tt></b>. </span></div><div class="footnote"><a name="fnidinternals2.structure.modstruct.struct-values.given-by-NMG" href="#fninternals2.structure.modstruct.struct-values.given-by-NMG"><sup>[5]</sup></a><span class="para footnote"> This field is filled in by <b><tt>NO_MODULE_GLOBALS</tt></b>. </span></div><div class="footnote"><a name="fnidinternals2.structure.modstruct.struct-values.given-by-PMG" href="#fninternals2.structure.modstruct.struct-values.given-by-PMG"><sup>[6]</sup></a><span class="para footnote"> This field is filled in by <b><tt>PHP_MODULE_GLOBALS</tt></b>. </span></div><div class="footnote"><a name="fnidinternals2.structure.modstruct.struct-values.only-with-ZTS" href="#fninternals2.structure.modstruct.struct-values.only-with-ZTS"><sup>[7]</sup></a><span class="para footnote"> This field only exists when <b><tt>USING_ZTS</tt></b> is <b><tt>TRUE</tt></b>. </span></div><div class="footnote"><a name="fnidinternals2.structure.modstruct.struct-values.only-without-ZTS" href="#fninternals2.structure.modstruct.struct-values.only-without-ZTS"><sup>[8]</sup></a><span class="para footnote"> This field only exists when <b><tt>USING_ZTS</tt></b> is <b><tt>FALSE</tt></b>. </span></div><div class="footnote"><a name="fnidinternals2.structure.modstruct.struct-values.given-by-SMPE" href="#fninternals2.structure.modstruct.struct-values.given-by-SMPE"><sup>[9]</sup></a><span class="para footnote"> This field is filled in by <b><tt>STANDARD_MODULE_PROPERTIES_EX</tt></b>. </span></div></td></tr></tbody></table> <div id="internals2.structure.modstruct.filling-it-in" class="sect2"> <h3 class="title">Filling in the structure in a practical situation</h3> <p class="para"> With all these fields to play with, it can be confusing to know which to use for what purpose. Here is the <i>zend_module</i> definition from the "counter" example extension after updating it to its final form. </p> <div class="example" id="internals2.structure.modstruct.filling-it-in.counter-mod-ex" name="internals2.structure.modstruct.filling-it-in.counter-mod-ex"> <p><b>Example #3 Counter extension module definition</b></p> <div class="example-contents"><div class="cdata"><pre>/* {{{ counter_module_entry */zend_module_entry counter_module_entry = { STANDARD_MODULE_HEADER, "counter", counter_functions, PHP_MINIT(counter), PHP_MSHUTDOWN(counter), PHP_RINIT(counter), PHP_RSHUTDOWN(counter), PHP_MINFO(counter), NO_VERSION_YET, PHP_MODULE_GLOBALS(counter), PHP_GINIT(counter), PHP_GSHUTDOWN(counter), NULL, STANDARD_MODULE_PROPERTIES_EX};/* }}} */</pre></div> </div> </div> <ul class="itemizedlist"> <li class="listitem"> <span class="simpara"> <b><tt>STANDARD_MODULE_HEADER</tt></b> is used since this module doesn't define any dependencies. </span> </li> <li class="listitem"> <span class="simpara"> "counter" is the extension's name, and is used to define the various callback functions the module passes to Zend. "counter" uses module, globals, and request functions at startup and shutdown times, and provides information to <a href="function.phpinfo.html" class="function">phpinfo()</a>, so all seven callbacks are defined. </span> </li> <li class="listitem"> <span class="simpara"> It is assumed that there is a variable of type <span class="type zend_function_entry *">zend_function_entry *</span> named <var class="varname">counter_functions</var> earlier in the file that contains the module definition, listing the functions the module exports to userspace. </span> </li> <li class="listitem"> <span class="simpara"> <b><tt>NO_VERSION_YET</tt></b> is a particularly nice way of telling Zend the module doesn't have a version. It might have been more correct to place <i>"1.0"</i> here instead in a real module. </span> </li> <li class="listitem"> <span class="simpara"> "counter" uses per-module globals, so <b><tt>PHP_MODULE_GLOBALS</tt></b> is used </span> </li> <li class="listitem"> <span class="simpara"> This module has no post-deactivate function, so <b><tt>NULL</tt></b> is used. </span> </li> <li class="listitem"> <span class="simpara"> Since this module <em class="emphasis">does</em> use globals, <b><tt>STANDARD_MODULE_PROPERTIES_EX</tt></b> is used to finish the structure. </span> </li> </ul> </div> <div id="internals2.structure.modstruct.php53" class="sect2"> <h3 class="title">What's changed between 5.2 and 5.3?</h3> <p class="simpara"> Nothing. The only differences in the <i>zend_module</i> structure between PHP 5.2 and PHP 5.3 are a few <span class="modifier">const</span> keywords. </p> </div> </div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="internals2.structure.basics.html">Basic constructs</a></div> <div class="next" style="text-align: right; float: right;"><a href="internals2.structure.globals.html">Extension globals</a></div> <div class="up"><a href="internals2.structure.html">Extension structure</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -