Detailed explanation of how to modify memory_limit memory limit in PHP_PHP tutorial

WBOY
Release: 2016-07-13 17:00:21
Original
1146 people have browsed it

Today, I installed a php environment on a new server, but when running it prompted a Fatal Error: Allowed memory size of xxxxxx bytes exhausted, which means there is insufficient memory. Let me introduce several ways to solve these problems.

Solution

Method 1: Edit php.ini In php.ini

Find the "memory_limit" item. If not, you can add this parameter yourself at the end of the file. Here are some setup examples

memory_limit = 128M; You can change 128M to any value you want to set


Method 2: .htaccess

Note: This method only takes effect when php is executed with the Apache module. Find the ".htaccess" file in the root directory of your website. If you don't have one, you can create one yourself. Then put the following configuration into it

php_value memory_limit 128M; You can change 128M to any value you want to set

Method 3: Modify PHP’s memory settings at runtime

Just add the following command line to your php code.

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

Friendly reminder

If you are using php5.2.17, the above methods may not work for you. This official bug cannot solve some problems. We can only reinstall the php environment, such as php5.4

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631258.htmlTechArticleToday I installed a php environment on a new server but when running it prompted Fatal Error: Allowed memory size of xxxxxx bytes exhausted, it’s because of insufficient memory. Let me introduce the solution...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template