問題描述
致命錯誤:允許的內存大小為 67108864 字節已用完(嘗試分配 13965430 字節)
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 13965430 bytes)
PHPInfo 顯示我的 memory_limit 為 128M,所以我很困惑為什么錯誤說我只有 64M.phpinfo 有沒有可能報錯?還是讓PHP使用兩個獨立的php.inis?
PHPInfo shows that I have a memory_limit of 128M, so I'm confused as to why the error says I only have 64M. Is it possible for phpinfo to report incorrectly? Or for PHP to use two separate php.inis?
該錯誤是由我的一位同事在我不知情的情況下添加的主要 php 文件之一中的 ini_set 調用引起的.
The error was being caused by an ini_set call in one of the primary php files that a co-worker of mine added without my knowledge.
推薦答案
PHP 的配置可以多處設置:
PHP's config can be set in multiple places:
- 主系統
php.ini
(通常在/etc某處) - Apache 配置中的某處(httpd.conf 或每個站點的 .conf 文件,通過
php_value
) - CLI &CGI 可以有不同的
php.ini
(使用命令php -i | grep memory_limit
檢查 CLI 配置) - 本地 .htaccess 文件(還有
php_value
) - 腳本內(通過
ini_set()
)
- master system
php.ini
(usually in /etc somewhere) - somewhere in Apache's configuration (httpd.conf or a per-site .conf file, via
php_value
) - CLI & CGI can have a different
php.ini
(use the commandphp -i | grep memory_limit
to check the CLI conf) - local .htaccess files (also
php_value
) - in-script (via
ini_set()
)
在 PHPinfo 的輸出中,Master"值是編譯后的默認值,Local"值是實際生效的值.它可以與默認值保持不變,也可以在上述任何位置被覆蓋.
In PHPinfo's output, the "Master" value is the compiled-in default value, and the "Local" value is what's actually in effect. It can be either unchanged from the default, or overridden in any of the above locations.
另請注意,PHP 通常具有不同的 .ini 文件用于命令行和基于網絡服務器的操作.從命令行檢查 phpinfo()
將報告與在基于 Web 的腳本中運行它不同的值.
Also note that PHP generally has different .ini files for command-line and webserver-based operation. Checking phpinfo()
from the command line will report different values than if you'd run it in a web-based script.
這篇關于已用完 X 字節的允許內存大小的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!