php PHP中\x00、\x04是什么意思
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1182812/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the meaning of \x00 , \x04 in PHP
提问by coderex
i have some codes having the \x00and \x04hex 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 line2I want to write these into a external file as binary format.
将在发生什么一号线2号线和我想写这些到外部文件的二进制格式。
where do i get all information like this.
我从哪里得到这样的所有信息。
回答by Philippe Gerber
\xindicates hexadecimal notation. See: PHP strings
\x表示十六进制表示法。请参阅:PHP 字符串
Have a look at an ASCII tableto see what 0x00 and 0x04 represent.
查看ASCII 表以了解 0x00 和 0x04 代表什么。
0x00 = NULL
0x04 = EOT (End of transmission)
回答by Nosredna
\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.
\x 是一种表示接下来的两个字符代表十六进制数字的方法。两个十六进制数字(每个数字 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 表。
回答by Kawa
\x04 is End of Transmission in ASCII. This holds up in most C-like languages.
\x04 是 ASCII 中的传输结束。这适用于大多数类 C 语言。
回答by fresskoma
\x00 is a Null-character
\x04 is a End-of-transmission-character
回答by Gumbo
\xHHis an escape sequence that describes the byte with that hexadecimal value.
\xHH是一个转义序列,用于描述具有该十六进制值的字节。
So \x00describes the byte with the value 0, \x04the byte with the value 4. Note that this escape sequence is only interpolated in double quoted strings.
So\x00描述值为 0\x04的字节,值为 4 的字节。请注意,此转义序列仅插入双引号字符串中。

