Why Does PHP Report a Higher Memory Limit in phpinfo() Than the Actual Allowed Size?

Patricia Arquette
Release: 2024-11-08 18:44:01
Original
300 people have browsed it

Why Does PHP Report a Higher Memory Limit in phpinfo() Than the Actual Allowed Size?

Mistaken Memory Limit: "Allowed memory size of X bytes exhausted"

Encountering the error "Allowed memory size of 67108864 bytes exhausted," despite phpinfo reporting a memory_limit of 128M, is not uncommon. Let's delve into the reasons behind this discrepancy.

PHP's configuration settings can be set in several locations:

  • Master system php.ini
  • Apache configuration (php_value)
  • CLI & CGI php.ini
  • Local .htaccess
  • In-script (ini_set())

PHPinfo displays the "Master" value as the default and the "Local" value as the active configuration. The active configuration can be overridden in any of the locations mentioned above.

Notably, PHP maintains separate .ini files for command-line and webserver operations. The memory limit reported by phpinfo() in a command-line context may differ from that reported in a web script.

In the specific instance, an ini_set() call in a primary php file, unbeknownst to the user, was modifying the memory limit, resulting in the error message despite the phpinfo reporting a higher value.

The above is the detailed content of Why Does PHP Report a Higher Memory Limit in phpinfo() Than the Actual Allowed Size?. For more information, please follow other related articles on the PHP Chinese website!

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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template