(the following is my best guess on how all this works -- corrections welcomed in the comments)
The STD_PHP_INI_ENTRY
and STD_PHP_INI_ENTRY_EX
macros allow an end-user-programmer to create ini settings whose values are saved in memory (and, presumably, can be set and fetched via ini_set
/ini_get
). The PHP_INI_ENTRY
and PHP_INI_ENTRY_EX
macros allow an end-user-programmer to create ini settings that trigger a callback function once, and then take some action in their own program/extension (i.e. setting some global-ish state in their program not related to PHP's ini system).
The _EX
version of the macros take an extra parameter -- this extra parameter is a callback that PHP will use to display the ini value in places like phpinfo
. For example, you cam see the ldap.maxlinks
ini definition here with a display_link_numbers
callback. The source then defines the display_link_numbers
callback here.
The STD_
macros are designed to work with a specific sort of state object/structs. Using the above ldap.maxlinks
example again, the three key parameters are max_links
, zend_ldap_globals
, and ldap_globals
.
STD_PHP_INI_ENTRY_EX("ldap.max_links", "-1", PHP_INI_SYSTEM, OnUpdateLong,
max_links, zend_ldap_globals, ldap_globals,
display_link_numbers)
Above, the zend_ldap_globals
parameters is the name of a struct definition, setup with the the ZEND_BEGIN_MODULE_GLOBALS
and ZEND_END_MODULE_GLOBALS
macros. You can see the macro calls that create the zend_ldap_globals
definition here. The above max_links
parameter is a field on this same struct.
Finally, the ldap_globals
parameter is an instance of that struct, created via the PHP_GINIT_FUNCTION
macro. This macro allows a programmer to setup a "per-php-request" global and (I think) is the memory where PHP will store the ini's value. You can see the ldap per-request global setup here.
When you've setup a struct to hold you ini's state like the above, you can then use a set of predefined PHP callbacks (OnUpdateLong
above) to have these values automatically set when the PHP user sets a value via php.ini
(or one of the various other places a PHP ini
value can be set, depending on which PHP_INI
constant you've passed to your STD_
macro (PHP_INI_SYSTEM
above)).