Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
是否可以将自定义字段添加到PHP ini文件?_Php - Fatal编程技术网

是否可以将自定义字段添加到PHP ini文件?

是否可以将自定义字段添加到PHP ini文件?,php,Php,我想知道是否可以将自定义字段添加到PHP ini文件中,并使用ini\u get函数获取它 此代码工作正常: ;PHP ini file mysqli.default_host=localhost # PHP code ini_get('mysqli.default_host') 但我想做这样的事情(不起作用): ;PHP ini file my_custom_field=custom_value # PHP code ini_get('my_custom_field') 有可能做到

我想知道是否可以将自定义字段添加到PHP ini文件中,并使用
ini\u get
函数获取它

此代码工作正常:

;PHP ini file
mysqli.default_host=localhost

# PHP code
ini_get('mysqli.default_host') 
但我想做这样的事情(不起作用):

;PHP ini file
my_custom_field=custom_value

# PHP code
ini_get('my_custom_field') 

有可能做到这一点吗?因为当我对自定义字段执行此操作时,它返回
false

php.ini
用于php配置,除非您正在进行扩展(用C编写),否则您可能不应该向其添加新选项。如果要为特定站点/应用程序进行配置,请在该项目的根目录中创建自己的
config.ini
文件。然后可以使用从中获取值


如果您真的必须将自定义条目添加到
php.ini
中,则可以使用,而不是。

为什么要这样做而不是使用.ini文件?在进行更改后是否重新启动了Web服务器?我对其进行了测试,但不起作用。这是问我是否真的不起作用或者我做错了什么。