0

I have some code in Wordpress that retrieves all Woocommerce product SKUs and is memory consuming (6000+ products)

So, at the start of my function I tried to increase the limit temporarily:

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

The result:

PHP Parse error:  syntax error, unexpected 'M' (T_STRING), expecting ',' or ')' 

I'm looking for an answer why this is wrong and I could not find it. Any ideas why this is happening?

1 Answers1

1

PHP ini_set() as follow.

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

OR

You can also try to change the memory_limit using either a php.ini or .htaccess file.

php.ini

memory_limit = 512M;

.htaccess

php_value memory_limit 512M

You can add this code in wp-config.php

define( 'WP_MEMORY_LIMIT', '512M' );
Rahul Gupta
  • 991
  • 4
  • 12
  • I want to change the memory_limit only when specific function is running, so no php.ini/.htaccess. Anyway, using double quotes instead of single solved the problem. Thanks! – Milan Marković Oct 04 '19 at 09:34