In PHP if I set the the memory 100M via ini_set
and then I set set_time_limit(0);
Does that mean that my PHP memory allocation is 100M forever(Until I restart my Apache)?
将内存设置为高,然后将set_time_limit设置为0
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- dongzhi6927 2012-09-16 23:52关注
No its reset back to the original at the end of script execution.
string ini_set ( string $varname , string $newvalue )
Sets the value of the given configuration option. The configuration option will keep this new value during the script's execution, and will be restored at the script's ending.
and
set_time_limit(0);
is treated the same.Example:
// 1. Script starts echo ini_get('memory_limit');//128M // 2. We set a new limit the script will now have 100M ini_set('memory_limit','100M'); echo ini_get('memory_limit'); //100M die; // 3. Script ends now its set back to 128M
With
set_time_limit(0);
it just tells the script to not time out, tho say you were to useset_time_limit(0);
within a loop then on each iteration its internal counter is set to 0 over and over.So if you were to use
set_time_limit(1);
within a loop as long as each iteration of the loop did not last longer then 1 second then it would still not time out asset_time_limit(n);
would reset the internal timeout counter to 0 on each iteration.Example of it not timing out after 1 second:
for($i=0;$i<=10;$i++){ set_time_limit(1); usleep(999998); //2micro seconds from a second echo $i; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥35 平滑拟合曲线该如何生成
- ¥100 c语言,请帮蒟蒻写一个题的范例作参考
- ¥15 名为“Product”的列已属于此 DataTable
- ¥15 安卓adb backup备份应用数据失败
- ¥15 eclipse运行项目时遇到的问题
- ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
- ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
- ¥15 自己瞎改改,结果现在又运行不了了
- ¥15 链式存储应该如何解决
- ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站