The example in this article describes the solution to the error Fatal error: Allowed memory size prompted by ThinkPHP. Share it with everyone for your reference. The specific analysis is as follows:
If your ThinkPHP prompts you: Fatal error (Fatal error: Allowed memory size), according to what is said on the Internet, increasing the memory that the server can use is not a good solution. There's no need to bother. Because this is a BUG in ThinkPHP itself.
Error message: Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 523800 bytes) in /var/www/www.example.com/ThinkPHP/Lib/Template/ ThinkTemplate.class.php on line 265.
If your error message is the same as mine, it also tells you that there is an error in the file ThinkTemplate.class.php, that is, it has an infinite loop when parsing its own tag include or other tags, causing the server to have insufficient memory. Used for recycling.
Solution:
1. Find the source of the problem. In the template page where the error (Fatal error: Allowed memory size) occurs, find the ThinkPHP tags you used (include/if/empty, etc.), delete the test one by one to see which tag is causing it;
2. Replace the tags you use with native PHP, such as:
If it is because of empty, you can refer to the above:
I hope this article will be helpful to everyone’s programming based on the ThinkPHP framework.