note 27919 added to function.ini-get
| From: | pollita@php.net | Date: | Wed, 25 Dec 2002 08:10:58 +0000 |
| Subject: | note 27919 added to function.ini-get | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-41273@lists.php.net to get a copy of this message | ||
The limitation on defining your own INI values is an intended feature of the Zend engine on which
PHP is based. However, if you're willing to do just a little extra work, you CAN define custom
INI values by adding a single line (or more for multiple INI entries) to the PHP source and
compiling yourself.
In ext/standard/basic_functions.c look for the following block:
PHP_INI_BEGIN()
PHP_INI_ENTRY_EX("safe_mode_protected_env_vars", SAFE_MODE_PROTECTED_ENV_VARS,
PHP_INI_SYSTEM, OnUpdateSafeModeProtectedEnvVars, NULL)
PHP_INI_ENTRY_EX("safe_mode_allowed_env_vars", SAFE_MODE_ALLOWED_ENV_VARS,
PHP_INI_SYSTEM, OnUpdateSafeModeAllowedEnvVars, NULL)
PHP_INI_END()
To add your own INI entry, just add another PHP_INI_ENTRY() line. For example, to create an INI
entry called "user.site_name" with a default value of "My First Website" that is
modifiable within any context your block would look like this:
PHP_INI_BEGIN()
PHP_INI_ENTRY_EX("safe_mode_protected_env_vars", SAFE_MODE_PROTECTED_ENV_VARS,
PHP_INI_SYSTEM, OnUpdateSafeModeProtectedEnvVars, NULL)
PHP_INI_ENTRY_EX("safe_mode_allowed_env_vars", SAFE_MODE_ALLOWED_ENV_VARS,
PHP_INI_SYSTEM, OnUpdateSafeModeAllowedEnvVars, NULL)
PHP_INI_ENTRY("user.site_name", "My First Website", PHP_INI_ALL, NULL)
PHP_INI_END()
At this point you can make/install the PHP source as normal and your resulting binary/module will
allow the additional ini value(s) you specified. (i.e.: ini_get("user.site_name") will
return "My First Website")
For more information on how to use PHP_INI_ENTRY, see the PHP manual section on "Extending
PHP"/"Working with INI values"
--
http://www.php.net/manual/en/function.ini-get.php
http://master.php.net/manage/user-notes.php?action=edit+27919
http://master.php.net/manage/user-notes.php?action=delete+27919
http://master.php.net/manage/user-notes.php?action=reject+27919