PHP 5.3.3 中的 ini_set("memory_limit") 根本不起作用 [英] ini_set("memory_limit") in PHP 5.3.3 is not working at all

查看:44
本文介绍了PHP 5.3.3 中的 ini_set("memory_limit") 根本不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前做过这个:

echo ini_get("memory_limit")."\n";
ini_set("memory_limit","256M");
echo ini_get("memory_limit")."\n";

那将输入这个:

32M
256M

在由命令行执行的 php 脚本上.我从 5.2 更新到 5.3,从现在开始,这个指令根本不起作用:这给了我:

on a php script executed by command line. I updated from 5.2 to 5.3, and from now, this directive is not working at all : this gives me :

32M
32M

然后让我的脚本失败并出现致命错误...

and then make my script fail with a fatal Error...

我检查了 php 文档,并用谷歌搜索了它,我没有找到任何地方memory_limit"已被弃用.

I checked the php documentation, and googled it, and I didn't find anywhere that "memory_limit" had been deprecated.

有人有解决办法吗?

推荐答案

很可能是您的 suhosin 更新了,这将 suhosin.memory_limit 的默认值从禁用更改为 0(这将不允许对 memory_limit 进行任何更新).

Most likely your sushosin updated, which changed the default of suhosin.memory_limit from disabled to 0 (which won't allow any updates to memory_limit).

在 Debian 上,更改/etc/php5/conf.d/suhosin.ini

On Debian, change /etc/php5/conf.d/suhosin.ini

;suhosin.memory_limit = 0

;suhosin.memory_limit = 0

suhosin.memory_limit = 2G

suhosin.memory_limit = 2G

或者任何你觉得舒服的值.您可以在 http://www.hardened-php.net/hphp 找到 Susosin 的更新日志/changelog.html,其中说:

Or whichever value you are comfortable with. You can find the changelog of Sushosin at http://www.hardened-php.net/hphp/changelog.html, which says:

改变了 memory_limit 保护的实现方式

Changed the way the memory_limit protection is implemented

这篇关于PHP 5.3.3 中的 ini_set("memory_limit") 根本不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆