Hi everyone i'm trying to make a script that can encode & decode FSK Frequency-shift keying
the problem i'm have so far is PHP Warning: pack(): Type h: illegal hex digit - line 37
here is my code
$RATE = 44100;
$maxVol = pow(2,15)-1.0;
$data = "";
for ($x=0; $x<=$RATE*3; $x++){
$vv = $maxVol*sin(2*pi()*$x*500/$RATE); #500Hz
$data+=pack('h',$vv); #this is line 37
}
echo $data;
pack in php seems like it does not support negative number & floats can someone please help me figure this out
The h
format code specifies input as a hex string. It's hard to tell this from the error, but the -
between the words digit
and line
is literally the character that is causing the error (ie it's not a separator in the message).
PHP Warning: pack(): Type h: illegal hex digit - line 37
^
In other words, your input is interpreted as a string containing the -
character, which is not a legal hex digit ( 0123456789abcdef
).
It's hard to give any specific advice on solving your problem without more information. At the very least, you need to review PHP's implementation of pack
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.