Page 1 of 1

Hex file data. How to evaluate it?

Posted: Sat Jul 19, 2003 7:05 pm
by garyshall
Having trouble parsing a file and checking for a particular hexadecimal value. Somebody help me out here.

$fp = fopen($file,"rb+");
$char = fgetc($fp);

if ($char == 0x4d)
{
echo "found it! ";
}

The first byte of this file is 4d hex, or "M" ASCII. This code won't find it. If I change to:

if ($char == "M")

Then is does trap the byte. What am I doing wrong? :cry: