views:

1165

answers:

5

i have some codes having the \x00 and \x04 hex codes, what does it means?

$str= implode("\x00", $var['message']); //line 1
$id= $var['message'] . "\x04" . $id;    //line 2

what will happen in the line1 and line2 I want to write these into a external file as binary format.

where do i get all information like this.

+2  A: 

\x is a way to indicate that the next two characters represent hexadecimal digits. Two hexadecimal digits (each of them 4 bits) make a byte.

If you want to know what the decimal version is, multiply the left numeral by 16 and add it to the right numeral, keeping in mind that "a" is 10, "b" is 11, etc.

In other programming languages, a dollar sign or the sequence 0x can also be used to flag hexadecimal numbers.


The numbers can represent anything. Sometimes they are control codes. Check an ASCII table.

Nosredna
+1  A: 

\x04 is End of Transmission in ASCII. This holds up in most C-like languages.

Kawa
Good point. An ASCII table may be useful here.
Nosredna
http://en.wikipedia.org/wiki/ASCII
Kawa
+8  A: 

\x indicates hexadecimal notation. See: PHP strings

Have a look at an ASCII table to see what 0x00 and 0x04 represent.

0x00 = NULL
0x04 = EOT (End of transmission)
Philippe Gerber
+1 - Great answer.
karim79
+1  A: 

\xHH is an escape sequence that describes the byte with that hexadecimal value.

So \x00 describes the byte with the value 0, \x04 the byte with the value 4. Note that this escape sequence is only interpolated in double quoted strings.

Gumbo
+1  A: 

\x00 is a Null-character
\x04 is a End-of-transmission-character

x3ro