open and read a binary file, show contents as hex...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mickey
Forum Newbie
Posts: 24
Joined: Thu May 01, 2003 11:14 am
Location: Philippines

open and read a binary file, show contents as hex...

Post by mickey »

hello,

i need to open a file and show it's contents as hex...

any ideas how? is there a function in PHP that will do this? byte per byte?

for instance,

$filePointer = fopen("logo.otb", "r");

$byte = fgets($filePointer, 1); // read byte per byte

// now how do i print byte as hex?

many thanks.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

mickey
Forum Newbie
Posts: 24
Joined: Thu May 01, 2003 11:14 am
Location: Philippines

Post by mickey »

right, thanks a lot. :)
Post Reply