PHP_INI_BEGIN( )
STD_PHP_INI_ENTRY("foo.my_ini_setting", "0", PHP_INI_ALL, OnUpdateInt,
setting, zend_foo_globals, foo_globals)
PHP_INI_END( )
The functions available to you are:
OnUpdateBool
OnUpdateInt
OnUpdateReal
OnUpdateString
OnUpdateStringUnempty
However, there may be cases where you want to check the contents of
an INI setting for validity before letting it be set, or there may be
things you need to call to initialize or reconfigure when one of
these settings is changed. In those cases, you will have to write
your own change-handling function.
When you have a custom change handler, you use a simpler INI
definition. In place of STD_PHP_INI_ENTRY( ), as
shown previously, use:
PHP_INI_ENTRY("foo.my_ini_setting", "0", PHP_INI_ALL, MyUpdateSetting)
The MyUpdateSetting( ) function can then be
defined like this:
static PHP_INI_MH(MyUpdateSetting) {
int val = atoi(new_value);
if(val>10) {
return FAILURE;
}
FOO_G(value) = val;
return SUCCESS;
}
#define PHP_INI_MH(name) int name(zend_ini_entry *entry, char *new_value, \
uint new_value_length, void *mh_arg1, \
void *mh_arg2, void *mh_arg3, int stage \
TSRMLS_DC)
The extra mh_arg1, mh_arg2, and
mh_arg3 are custom user-defined arguments that you
can optionally provide in the INI_ENTRY section.
Instead of using PHP_INI_ENTRY( ) to define an INI
entry, use PHP_INI_ENTRY1( ) to provide one extra
argument, PHP_INI_ENTRY2( ) for two, and
PHP_INI_ENTRY3( ) for three.
REGISTER_INI_ENTRIES( );
In the PHP_MSHUTDOWN_FUNCTION( ), add:
UNREGISTER_INI_ENTRIES( );
In the PHP_MINFO_FUNCTION( ), you can add:
DISPLAY_INI_ENTRIES( );
This will show all the INI entries and their current settings on the
phpinfo( ) page.
 |  |  |
14.11. Creating Variables |  | 14.13. Resources |