note 27919 deleted from function.ini-get by sniper
| From: | sniper@php.net | Date: | Fri, 24 Oct 2003 12:24:29 +0000 |
| Subject: | note 27919 deleted from function.ini-get by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-59219@lists.php.net to get a copy of this message | ||
Note Submitter: pollita@php.net
----
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"