ini_set()的作用范围? [英] ini_set() scope of effect?
问题描述
我有index.php
和级联包含的几个文件,诸如此类.
I've had index.php
and several files which cascading include,something like this.
index.php -> controller.php -> model.php -> view.php
在model.php
中,我有一个使用ini_set('memory_limit', '-1');
ini_set()
的更改何时到期?
When will the ini_set()
change of the setting expire?
执行后index.php
?还是view.php
?还是model.php
中的功能?
After executed index.php
? Or view.php
? Or the function in model.php
?
推荐答案
ini_set()
是全局,用于脚本中发生的所有事情(不仅仅是当前文件:整个执行线程对于整个一个请求);调用它的时间无关紧要,它将始终影响此脚本的 global 设置.当您的脚本终止时,效果将终止-例如通过exit
,die
或从index.php
的末尾开始.
ini_set()
is global for everything that happens in the script (not just the current file: the whole thread of execution that is occurring), for this entire one request; it doesn't matter whence you invoke it, it will always affect the global settings for this script. The effect will expire when your script terminates - e.g. through exit
, die
, or running off the end of index.php
.
它不会影响其他同时运行的脚本(需要自己调用ini_set
的脚本),也不会持久存在于以后的请求中(如果需要持久设置,则需要编辑php.ini
).
It will not affect any other scripts running simultaneously (those need to call ini_set
themselves), and it will not persist into later requests (if you need persistent settings, you need to edit php.ini
).
请注意,文档说的是同一件事:
设置给定配置选项的值.配置选项将在脚本执行期间保留此新值,并将在脚本结尾处还原.
Sets the value of the given configuration option. The configuration option will keep this new value during the script's execution, and will be restored at the script's ending.
由于显然尚不清楚:使用ini_set
更改的值将对整个脚本开始有效.当前执行的位置(在哪个文件,哪个类,什么函数中)都无关紧要;各地的设置都一样.它将保持不变,直到您再次对其进行更改或整个脚本终止为止. (不是当前文件,不是当前函数;整个脚本)
Since it is apparently unclear: the value you change using ini_set
will be valid for the whole script onwards. It doesn't matter where the execution currently is (in what file, in what class, in what function); the setting will be the same, everywhere. It will remain so until you change it again, or until the whole script terminates. (not the current file, not the current function; the whole script)
这篇关于ini_set()的作用范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!