How to modify PHP’s memory limit

In PHP development, sometimes we need to increase the memory limit of PHP in order to process large amounts of data or perform memory-intensive operations. This article will describe how to modify PHP's memory limit.

PHP's memory limit is controlled by the memory_limit parameter in the configuration file php.ini. By default, the value of this parameter is usually set to a low number, such as "128M", to limit the amount of memory used by the script. To modify the memory limit, follow these steps:

  1. Locate the php.ini file: First, we need to find the php.ini file that is being used. You can find the location of this file by using the function in your PHP code phpinfo(). Create a phpinfo.phpfile named and add the following code to the file:
<?php
phpinfo();
?>

Save the file and access it through your browser (for example: http://localhost/phpinfo.php). In the output page, look for the "Loaded Configuration File" field, which will display the full path to the php.ini file being used.

  1. Edit the php.ini file: Open php with a text editor

Guess you like

Origin blog.csdn.net/ShAutoit/article/details/133535941