PHP警告:unpack():类型n:输入不足 - 日志条目 [英] PHP Warning: unpack(): Type n: not enough input - log entry

查看:1351
本文介绍了PHP警告:unpack():类型n:输入不足 - 日志条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我发现这个错误日志

So I have found this error log

PHP Warning:  unpack(): Type n: not enough input, need 2, have 0 in {{file}}{{line}}

中有0,所述文件和行包含此代码:

the said file and line contains this code:

$answerHeader    = unpack('ntype/nclass/Nttl/nlength', $answerHeaderBin);

这是在DNS上进行查询的代码的一部分。
我的问题是我不知道如何调试这个。如果我尝试转储前面提到的标题信息是正确的。我尝试unpack()没有参数,它只是返回false,没有错误。

This is part of a code which makes a query on a DNS. My issue is that I don;t know how to debug this. If I try to dump the before mentioned header the information is correct. I tried unpack() with no arguments and it just returns false with no errors.

所以我猜,我的问题是:在哪种情况下会出现警告登录?

So I guess, my question is: In which situation would that warning appear in the error log?

推荐答案

当输入数据不正确时,特别是如果预期更多的字符解压缩在这种情况下,unpack()函数的计算结果为false。

Turns out that the warning appears when the input data is not correct, specifically if it expects more characters to unpack than the provided amount, in this case the unpack() function evaluates to false.

这篇关于PHP警告:unpack():类型n:输入不足 - 日志条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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