I want to know if is possible to add custom fields to the PHP ini file and get it with the ini_get
function.
This code works fine:
;PHP ini file
mysqli.default_host=localhost
# PHP code
ini_get('mysqli.default_host')
But I want to do something like this (isn't working):
;PHP ini file
my_custom_field=custom_value
# PHP code
ini_get('my_custom_field')
Is possible to do this? Because when I do this to custom fields, it returns false
.
php.ini
is for PHP configuration, unless you are making an extension (written in C) you probably shouldn't add new options to it. If you are making a configuration for a specific site/application create your own config.ini
file inside that project's root. You can then use parse_ini_file to get the values from it.
If you really must add custom entries to your php.ini
you can get them using get_cfg_var, not ini_get.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With