|
Posted by Yandos on 06/06/06 20:59
Hi all,
I'd like to work with a binary file....
I read the whole file into variable (it conatains binary data from 00-FF):
$fp=fopen($cfg,"r");
$content=fread($fp,filesize($cfg));
fclose($fp);
// and then I'd like to check if it contains special binary sequence, let's say bytes "00 01
02 03":
$replacestring="/\x00\x01\x02\x03/im";
if (preg_match($replacestring,$content)==0) {
echo("bad input file format");
exit();
}
but i get error message:
<b>Warning</b>: preg_match(): No ending delimiter '/' found in <b>test.bat</b> on
line <b>57</b><br />
I think it is maybe because php uses strings terminated with null, but can i force php to
use strings with predefined length for example? Is there a way to work with strings
containing null characters?
Thank you in advance.
Y.
Navigation:
[Reply to this message]
|