简体   繁体   English

PHP中\ x00,\ x04的含义是什么?

[英]What is the meaning of \x00 , \x04 in PHP

i have some codes having the \\x00 and \\x04 hex codes , what does it means? 我有一些代码有\\ x00\\ x04 十六进制代码 ,这意味着什么?

$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 . line1和line2会发生什么我想把它们作为二进制格式写入外部文件。

where do i get all information like this. 我在哪里可以获得这样的所有信息。

\\x indicates hexadecimal notation. \\x表示十六进制表示法。 See: PHP strings 请参阅: PHP字符串

Have a look at an ASCII table to see what 0x00 and 0x04 represent. 看一下ASCII表 ,看看0x00和0x04代表什么。

0x00 = NULL
0x04 = EOT (End of transmission)

\\x is a way to indicate that the next two characters represent hexadecimal digits. \\ x是一种表示接下来的两个字符代表十六进制数字的方法。 Two hexadecimal digits (each of them 4 bits) make a byte. 两个十六进制数字(每个都是4位)构成一个字节。

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. 如果你想知道十进制版本是什么,将左数字乘以16并将其加到右边的数字,记住“a”是10,“b”是11,等等。

In other programming languages, a dollar sign or the sequence 0x can also be used to flag hexadecimal numbers. 在其他编程语言中,美元符号或序列0x也可用于标记十六进制数字。


The numbers can represent anything. 数字可以代表任何东西。 Sometimes they are control codes. 有时它们是控制代码。 Check an ASCII table . 检查ASCII表

\\x04 is End of Transmission in ASCII. \\ x04是ASCII格式的传输结束。 This holds up in most C-like languages. 这在大多数类C语言中都有用。

\\x00 is a Null-character \\ x00是一个空字符
\\x04 is a End-of-transmission-character \\ x04是传输结束字符

\\x HH is an escape sequence that describes the byte with that hexadecimal value. \\x HH是一个转义序列,用于描述具有该十六进制值的字节。

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 . 所以\\x00描述了值为0的字节, \\x04描述了值为4的字节。请注意,此转义序列仅以双引号字符串进行插值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM