apache 来自 PHP 导入脚本的未初始化字符串偏移错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/185240/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Uninitialized string offset error from PHP import script
提问by da5id
I have an import-from-excel script as part of a CMS that previously ran without issue.
我有一个 import-from-excel 脚本,作为以前运行没有问题的 CMS 的一部分。
My shared-hosting provider has recently upgraded their infrastructure, including PHP from 5.1 to 5.2.6, and the script now returns "Uninitialized string offset: -XXX in /path/scriptname.php on line 27" (XXX being a decreasing number from 512 and /path/scriptname.php of course being the full path to script in question).
我的共享主机提供商最近升级了他们的基础架构,包括 PHP 从 5.1 到 5.2.6,并且脚本现在返回“未初始化的字符串偏移:-XXX in /path/scriptname.php on line 27”(XXX 是从512 和 /path/scriptname.php 当然是相关脚本的完整路径)。
It returns this error for every line of the excel file. Line 27 is just a return from within a function that is the first point at which the imported data is being processed:
它为 excel 文件的每一行返回此错误。第 27 行只是一个函数内部的返回,它是处理导入数据的第一个点:
function GetInt4d($data, $pos) {
return ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | (ord($data[$pos+3]) << 24);
}
It finally implodes with a "Fatal error: Allowed memory size of 47185920 bytes exhausted (tried to allocate 71 bytes) in /path/scriptname.php on line 133".
它最终以“致命错误:第 133 行的 /path/scriptname.php 中的 47185920 字节允许内存大小耗尽(试图分配 71 字节)”而崩溃。
There's nothing useful in Apache error logs. I am stumped. Anyone have any ideas of at least where to look? Even knowing if it's likely to be something within my script or something to do with upgrade would be useful. I had another issue with a different site on same provider that (after upgrade) couldn't write sessions to tmp directory (since resolved), but am pretty sure it's not that (?).
Apache 错误日志中没有任何用处。我难住了。任何人都有任何想法至少在哪里看?即使知道它是否可能是我的脚本中的某些内容或与升级有关的内容也会很有用。我在同一提供商的不同站点上遇到了另一个问题,该问题(升级后)无法将会话写入 tmp 目录(已解决),但我很确定这不是那个 (?)。
EDIT: As it turned out that the answer was to do with the version of the parser being incompatible in some way with PHP 5.2.6, I thought it might be of use to someone that the parser in question is Spreadsheet Excel Reader.
编辑:事实证明,答案与解析器的版本在某种程度上与 PHP 5.2.6 不兼容有关,我认为它可能对有问题的解析器是Spreadsheet Excel Reader 的人有用。
采纳答案by Till
Uninitialized string offset:
未初始化的字符串偏移量:
... means that $datais not an array.
... 表示这$data不是数组。
回答by da5id
回答by da5id
Thanks for the input, the situation has 'resolved itself' via me finding a more recent version of the parsing library I was using. My guess is the issue was something to do with the difference between php versions, though I'm unsure exactly what. Fixed but frustrating.
感谢您的输入,通过我找到了我正在使用的解析库的更新版本,这种情况已经“自行解决”。我的猜测是这个问题与 php 版本之间的差异有关,尽管我不确定到底是什么。固定但令人沮丧。
EDIT: I'm going to accept Till's answer purely in the interests of closing the question. Thx again for input.
编辑:我将接受 Till 的回答,纯粹是为了结束这个问题。再次输入。

