PHP ini_set memory limit

user6618536 picture user6618536 · Mar 3, 2017 · Viewed 18.8k times · Source

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

Answer

Radon8472 picture Radon8472 · Mar 3, 2017

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