0

I am reading binary data from a network socket in PHP. With files, you can use the 'b' mode to specify that the file is binary and should be read as such, but how does one mark a network socket as being binary?

4

2 回答 2

1

网络套接字总是被假定为二进制数据,所以这个标志不是必需的。基于文件的操作的标志的“二进制”名称选择得有些糟糕。它应该是“不翻译行尾字符”标志。

否则,显而易见的读数是,如果您不指定b,则应以模拟模式读取文件。

于 2011-06-27T16:26:43.207 回答
0

使用unpack()是 php 如何读取二进制数据。

//example:
$un = unpack("V",$some_bin_string);
于 2011-06-27T16:26:15.487 回答