PHP 中的数组大小限制 [英] Array size limit in PHP

查看:149
本文介绍了PHP 中的数组大小限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道 php 5 中的数组是否有大小限制?我编写了一个 php 脚本来更改文件中每一行的最后一个元素.打印修改文件的内容,当我运行时小文件上的脚本(即每行包含 4 个值),它将起作用.当我在一个更大的文件(比如 60000 行,每行包含 90 个值)上运行它时,它不会改变原始文件的一点点,但脚本在运行时没有抛出任何异常消息.这是什么问题?

I am wondering is there a size limit for array in php 5? I wrote a php script to change the last element of each line in a file. print out the content of a modified file, when I run the script on a small-sized file (i.e. each line comprises 4 values), it will work. When I run it on a larger file (like 60000 lines, each of which comprises 90 values), it does not change a bit of the original file, but the script did not throw any exception message during runtime. What is this problem?

推荐答案

您可能会耗尽内存,因为您的数组大小(理论上)仅受分配给脚本的内存量的限制.将 ini_set('memory_limit', '1024M'); 放在脚本的开头以将内存限制设置为 1 GB.为了获得最佳效果,您可能需要将其提高得更高.

You could be running out of memory, as your array size is (in theory) only limited by the amount of memory allocated to the script. Put ini_set('memory_limit', '1024M'); in the beginning of your script to set the memory limit to 1 GB. You may need to increase this even higher for best results.

这篇关于PHP 中的数组大小限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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