PHP ini_set memory limit

前提是你 提交于 2019-12-23 15:00:16

问题


When we use ini_set like below in code, will memory limit be the same for all other codes? or only valid for in which code we added ?

ini_set('memory_limit', '512M');

Thanks


回答1:


It is only working for the file where it is written. Best way to change settings for multiple phps in the same folder are:

1. creating a file named ".htaccess" with the line

php_value memory_limit '512M'

Keep in mind, this only works, if you server configuration allowes "AllowOverride" directive for this directory

2. adding a own php with your config options as auto-prepend-file

You can do this in php.ini.

3. changing value of "memory_limit" directly in you php.ini

but this will take affect to ALL php-files you are running




回答2:


It depends where you are adding.

If in a specific script then till that script is running. If setting at application level then it will be set for that specific application.



来源:https://stackoverflow.com/questions/42577935/php-ini-set-memory-limit

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