Home > Backend Development > PHP Problem > How to set the maximum memory in php

How to set the maximum memory in php

藏色散人
Release: 2023-03-09 19:28:01
Original
6938 people have browsed it

How to set the maximum memory in php: First set "memory_limit = 128M;" in php.ini; then set "ini_set('memory_limit', '128M');" through PHP's ini_set function.

How to set the maximum memory in php

The operating environment of this article: Windows 7 system, PHP version 7.1, DELL G3 computer

PHP modify the maximum execution time and maximum execution time of the script Memory limit

  • Three ways for PHP to set the maximum execution time of a script

Set it in php.ini

max_execution_time = 120;
Copy after login

Set by PHP's ini_set function

ini_set("max_execution_time", "120");
Copy after login

Set by set_time_limit function

set_time_limit(120);
Copy after login

If the above numbers are set to 0, there will be no limit, and the script will continue to execute.

  • Three ways to set the maximum memory limit of scripts in PHP

Set it in php.ini

memory_limit = 128M ;
Copy after login

Through PHP ini_set function settings

ini_set('memory_limit', '128M');
Copy after login

Modify Apache’s .htaccess file

Note: This method only takes effect when php is executed as an Apache module.

Find the ".htaccess" file in the root directory of your website. If not, you can create one yourself.

Then put the following configuration into it:

php_value memory_limit 128M ;
Copy after login

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to set the maximum memory in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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