Where does phpinfo() get its info?

只谈情不闲聊 提交于 2021-02-16 16:20:44

问题


If you run a phpinfo(); does it show exactly what is in the php.ini or if settings are changed on the fly via php with methods like ini_set() or via .htaccess will they be shown in phpinfo?


回答1:


phpinfo() shows, in the "Local Value" column, the current configuration ; i.e.

  • what is in php.ini
  • eventually, overriden in Apache's VirtualHost or in .htaccess files
  • eventually, overriden by ini_set

In the end, it shows the configuration values that would be / are used by your script.


As a sidenote : it also display informations that are not-really "configuration" per-se, like the configure line that was used to compile PHP, the version of the Zend Engine, ...




回答2:


It will show the current running environment, not just what is in php.ini. Anything that changes the environment like the methods you mentioned will be reflected.




回答3:


I think that's what the meaning of the "global" and "local" columns is - "global" is what's set in the central php.ini, "local" is whatever changes have been applied to the global setting using one of the methods you describe.




回答4:


If you use ini_set(), the changes are made on-the-fly for the current script only, it does not permanently change php.ini settings. The phpinfo() shows current settings of what is there in the php.ini file which is also influenced by apache and ini_set function.




回答5:


phpinfo() always display the settings value in 2 column. First column is the global value that set in php.ini file. Second column is per user value, that set in php.ini or can be override by .htaccess file or override through ini_set before calling phpinfo().

Please note that not all settings value can be override by .htaccess or ini_set. See the complete list here and take a look at Changeable column. See the explanation og the Changeable column value here.

Try it by yourself.



来源:https://stackoverflow.com/questions/2327830/where-does-phpinfo-get-its-info

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!