Why am i seeing 'fatal error: allowed memory size exhausted' in php?

This error is triggered when your script consumes more memory than allocated in `php.ini`. Example:

$array = [];
while (true) {
    $array[] = str_repeat('A', 1024 * 1024);

// Increase the memory_limit in php.ini or optimize your code
memory_limit = 512M;
Increasing memory is a temporary fix; always try to optimize your code to use memory efficiently.

Beginner's Guide to PHP