PHP Warning: unpack(): Type n: not enough input - log entry

有些话、适合烂在心里 提交于 2019-12-13 17:09:03

问题


So I have found this error log

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

the said file and line contains this code:

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

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?


回答1:


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.



来源:https://stackoverflow.com/questions/29941911/php-warning-unpack-type-n-not-enough-input-log-entry

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!