What causes "fatal error: allowed memory size exhausted" in php?

Example:

// A loop or recursive function that consumes more memory than allocated.
This error indicates that your script exceeded the memory limit set in the php.ini file.

Solution:

// Increase the memory_limit in php.ini or optimize your script.

Beginner's Guide to PHP