php ini_set 不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12618424/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ini_set not working
提问by Damiano Barbati
Here is the matter:
这是问题:
ini_set('display_errors', '1');
ini_set('safe_mode', '0');
ini_set('allow_url_fopen', '1');
ini_set('allow_url_include', '1');
print_r(ini_get_all());
And I get:
我得到:
Array(
[allow_url_fopen] => Array
(
[global_value] => 1
[local_value] => 1
[access] => 4
)
[allow_url_include] => Array
(
[global_value] =>
[local_value] =>
[access] => 4
)
Why I cannot set that variable within the php ini_set function? The directive is specified as PHP_INI_ALL then it can be defined within the ini_set() function! http://php.net/manual/en/ini.list.php
为什么我不能在 php ini_set 函数中设置该变量?该指令被指定为 PHP_INI_ALL 然后它可以在 ini_set() 函数中定义! http://php.net/manual/en/ini.list.php
采纳答案by Vijay Sarin
display_errors
display_errors
may be set at runtime (with ini_set()), but it won't have any affect if the script has fatal errors. This is because the desired runtime action does not get executed.
可以在运行时设置(使用ini_set()),但如果脚本有致命错误,则不会产生任何影响。这是因为未执行所需的运行时操作。
Use ini_set('display_errors','Off');
用 ini_set('display_errors','Off');
safe_mode
safe_mode
This feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0. This directive belongs to PHP_INI_SYSTEMand Cannot be set via ini_set()
此功能自 PHP 5.3.0 起已弃用,自 PHP 5.4.0 起已移除。该指令属于PHP_INI_SYSTEM并且不能通过设置ini_set()
allow_url_include
allow_url_include
Use ini_set('allow_url_include', 'On');
用 ini_set('allow_url_include', 'On');
allow_url_fopen
allow_url_fopen
This directive belongs to PHP_INI_SYSTEMand Cannot be set via ini_set()
该指令属于PHP_INI_SYSTEM并且不能通过设置ini_set()
回答by wroniasty
These variables cannot be changed within a user script. The accessvalue means:
这些变量不能在用户脚本中更改。该access值意味着:
PHP_INI_SYSTEM 4 Entry can be set in php.ini or httpd.conf
You can try to set it in .htaccess:
您可以尝试将其设置为.htaccess:
php_value allow_url_include 1
回答by ViRuSTriNiTy
My answer might be off-topic but I almost always come back to this question via Google when my ini_setcalls are not working. Sharing my case might help others to solve a issue with ini_setmore quickly.
我的回答可能偏离主题,但当我的ini_set电话无法正常工作时,我几乎总是通过 Google 回到这个问题。分享我的案例可能会帮助其他人ini_set更快地解决问题。
So, in my case display_errorsis disabled but PHP displays the errors in the browser anyway although I enabled log_errorsand set error_logto C:\Windows\Temp\PHP_error.log.
因此,在我的情况下display_errors已禁用,但 PHP 无论如何都会在浏览器中显示错误,尽管我启用log_errors并设置error_log为C:\Windows\Temp\PHP_error.log.
First impression is always that ini_set is not workingBUT it might be a permission issue. If PHP cannot access the log file then it will simply send the errors to the browser.
第一印象总是ini_set 不起作用,但它可能是权限问题。如果 PHP 无法访问日志文件,那么它只会将错误发送到浏览器。
Solution:make sure PHP has the permission to access and write the log file.
解决方法:确保PHP有访问和写入日志文件的权限。
回答by L0j1k
Have you tried putting boolean values instead of 0 or 1?
你有没有试过把布尔值而不是 0 或 1?
ini_set('display_errors', true);
ini_set('safe_mode', false);
ini_set('allow_url_fopen', true);
ini_set('allow_url_include', true);
print_r(ini_get_all());
Or try this:
或者试试这个:
ini_set('allow_url_include', 'on');
回答by artragis
allow_url_fopen can't be modified by ini_set. It's because some ini statements has to be declared in an ini file only.
allow_url_fopen 不能被 ini_set 修改。这是因为某些 ini 语句必须仅在 ini 文件中声明。
回答by ganesh pathak
if you get this message in zabbix interface "ini_set(): Use of mbstring.internal_encoding is deprecated"
如果你在 zabbix 界面收到这个消息 "ini_set(): Use of mbstring.internal_encoding is deprecated"
simply go to file vi /usr/local/share/zabbix/include/locales.inc.php and commet the line
只需转到文件 vi /usr/local/share/zabbix/include/locales.inc.php 并找到该行
# ini_set('mbstring.internal_encoding', 'UTF-8');"
restart httpd& zabbix-serverdaemons , then try.. thats it.!
重新启动httpd和zabbix-server守护进程,然后尝试..就是这样。!

