问题
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