php-excel-reader 允许的内存大小为 134217728 字节耗尽


php-excel-reader Allowed memory size of 134217728 bytes exhausted

require_once 'Excel/reader.php';
$data = new Spreadsheet_Excel_Reader();
$data->read('Senator.xls');

我在错误中收到以下错误.log

PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes)

奇怪的是,这在我的开发实例上工作得很好。但不是在生产中。我应该寻找什么差异。

注意:两个环境都有memory_limit=128M

可能一台服务器具有 64 位处理器。GetInt4d 位移不适用于 64 位处理器。

使用此技巧来确保 32 位和 64 位系统上 <<24 块的正确结果,只需将 GetInt4d 函数的代码替换为以下内容: 位置 : Excel/olereader.inc 行 no-27 ,函数 GetInt4d()

$_or_24 = ord($data[$pos+3]);

if ($_or_24>=128) $_ord_24 = -abs((256-$_or_24) << 24); else $_ord_24 = ($_or_24&127) << 24;

return ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | $_ord_24;

取决于女巫线,它给出了错误:我的是

PHP Fatal error:  Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in [] on line 1688

它是函数

addcell($row, $col, $string, $info=null) {

特别是foreach循环。据我了解,它是关于颜色单元格偏移或类似内容的信息,所以我对循环进行了注释,现在它使用的内存要少得多。

如果你不需要执行这样的代码,你可以注释并尝试。

相关文章: