kumaresan
kumaresan

Reputation: 83

Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes) in PHP

I am facing issue in my code, when I am trying to store the file_get_contents output into an obj.

$json = file_get_contents($url);
$obj = json_decode($obj);

I am not allowed to change the memory size in ini.php because it is on server.Any other solution for this.?

Upvotes: 0

Views: 1486

Answers (3)

samo
samo

Reputation: 1

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

or set bigger memory

Upvotes: 0

monxas
monxas

Reputation: 2657

Have you tried other options of increasing memory limit? Like

ini_set('memory_limit', '-1'); //change the -1 to a value that acommodates to your use case
$json = file_get_contents($url);
$obj = json_decode($json);

Upvotes: 1

Alex Tartan
Alex Tartan

Reputation: 6836

You have a simple typo:

$json = file_get_contents($url);
$obj = json_decode($json);

Upvotes: 2

Related Questions