简体   繁体   English

为什么未加载php.ini中的设置?

[英]Why isn't a setting in php.ini not being loaded?

I'm trying to get PHP to display a warning when we call an undefined variable. 我试图让PHP在调用未定义的变量时显示警告。

php.ini has the line error_reporting = E_ALL | E_STRICT php.ini中的行error_reporting = E_ALL | E_STRICT error_reporting = E_ALL | E_STRICT . error_reporting = E_ALL | E_STRICT

The trouble is, strict warning messages are not being output to the browser. 问题在于,没有将严格的警告消息输出到浏览器。

In the PHP script, echoing E_ALL | E_STRICT 在PHP脚本中,回显E_ALL | E_STRICT E_ALL | E_STRICT shows the value 32767 . E_ALL | E_STRICT显示值32767

Yet the value returned by error_reporting() is 22519 . 但是error_reporting()返回的值为22519 I've read online that this value actually matches E_ALL & ~E_NOTICE & ~E_DEPRECATED . 我已经在线阅读了该值实际上与E_ALL & ~E_NOTICE & ~E_DEPRECATED

Is the value in my php.ini for error_reporting potentially being overridden? 我的php.ini用于error_reporting的值是否可能被覆盖? If so, how would I investigate where its value is being set? 如果是这样,我将如何调查其值设置在哪里? error_reporting is not being set anywhere in the script. 未在脚本中的任何位置设置error_reporting I'm editing the correct php.ini file, as I'm editing /etc/php5/apache2/php.ini which is specified by phpinfo() . 我正在编辑正确的php.ini文件,因为我正在编辑phpinfo()指定的/etc/php5/apache2/php.ini

Edit 编辑

phpinfo() includes the following information: phpinfo()包含以下信息:

Loaded Configuration File   /etc/php5/apache2/php.ini

Additional .ini files parsed    /etc/php5/apache2/conf.d/curl.ini, /etc/php5/apache2/conf.d/gd.ini, /etc/php5/apache2/conf.d/mcrypt.ini, /etc/php5/apache2/conf.d/mysql.ini, /etc/php5/apache2/conf.d/mysqli.ini, /etc/php5/apache2/conf.d/pdo.ini, /etc/php5/apache2/conf.d/pdo_mysql.ini 

error_reporting no value (Local)    no value (Master)

I think you have to reload apache after changing the php.ini file, in order to see the changes take effect. 我认为您必须在更改php.ini文件后重新加载apache才能看到更改生效。 Depending on your distribution something like sudo service apache2 reload or sudo /etc/init.d/apache2 reload should do the job. 根据您的发行版,诸如sudo service apache2 reloadsudo /etc/init.d/apache2 reload之类的工作即可完成。

The problem was that I had introduced a syntax error into php.ini . 问题是我在php.ini中引入了语法错误

I presume that the values I mentioned in my question from phpinfo() were PHP's default values that it sets. 我假设我在问题中从phpinfo()中提到的值是它设置的PHP默认值。 They were not getting touched, since PHP was not able to load its ini file. 由于PHP无法加载其ini文件,因此并未受到影响。

Thanks to all who responded here helping to debug the issue. 感谢所有在这里做出回应的人,以帮助调试问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM