Link to home
Start Free TrialLog in
Avatar of tonelm54
tonelm54

asked on

Write to file using Hex

Is it possible to write to a file in PHP using HEX?

I have a HEX string, which needs to be written back into a file.

Any ideas?

Thank you
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Yes, it's possible.  String variables can have any kind of data.
If you want to post the hex string, I will be glad to show you how it can work.
greetings tonelm54, , HEX is just a string that only has 16 letters and numbers in it, using only = "abcdef1234567890", so your question does not make much sense as "Is it possible to write to a file in PHP using HEX?"
Can you explain what your problem is with more information, have you written to a file before, do you need PHP methods to write to file, or what is it in PHP that you need information about? ?
ASKER CERTIFIED SOLUTION
Avatar of liveaspankaj
liveaspankaj
Flag of Nepal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The accepted solution cannot possibly work because it has no "start PHP" tag and it uses an undefined variable.  You might want to get some foundation in how PHP works.  These are two learning resources that will help you get started.
http://us.php.net/tut.php
http://www.sitepoint.com/books/phpmysql4/

Fortunately for all of us, the PHP functions are well-documented in the online man pages.  You can see the fwrite() example in the link below.  It is worth reading carefully.  Note that fwrite() provides return values.  You cannot just call fwrite() and assume that it wrote something.  You must test the return values from fwrite() to know whether it worked or not.  You might also want to read the notes carefully.  One of the notes says, On systems which differentiate between binary and text files (i.e. Windows) the file must be opened with 'b' included in fopen() mode parameter..  This is why I asked you to post the data you are working with (ID:37056558).  Sometimes at EE you will get an answer that has not been tested and may not be well-thought-out.  Caveat Emptor.
http://us3.php.net/manual/en/function.fwrite.php