Hello,
I am trying to get my head around dealing with binary data and PHP - not having great success.
At present I want to parse in binary data from a file in chunks. As an example this is my tet php.
Code: Select all
$filename="test.bin";
$handle=fopen($filename,"rb");
$byte=fread($handle,1);
fclose($handle);
echo "1st byte is $byte";
Now this reads the first byte from my test file. This is 01 when viewed in a Hex editor so Binary 00000001 and 1 in decimal. I know I am reading the value correctly - if I write it back into a new binary file it shows as 01 again so the vlue is correct. But the echo above display just a nonsense charcater. How do I convert the variable $byte into either a decimal value or a binary value that I can manipulate in PHP?
Many thanks
Scott