简体   繁体   English

如何从PHP中的C#BinaryWriter读取二进制流?

[英]How to read a binary stream from C# BinaryWriter in PHP?

Is there anything open source available for this? 是否有任何开源可用?

or 要么

Is there a way to parse a stream of bytes received from a POST request manually and convert the chunks of bytes to the appropriate data types? 有没有办法手动解析从POST请求接收到的字节流并将字节块转换为适当的数据类型?

I'm not sure if there is anything open source for this, but PHP does support the needed features out of the box. 我不确定是否有开源的功能,但是PHP确实支持所需的功能。

the contents of a POST request can be retrieved as follows: POST请求的内容可以按以下方式检索:

$data = file_get_contents("php://input");

// or to handle the data as a stream
$stream = fopen("php://input", "rb");

The above is the preferred method, as $HTTP_RAW_POST_DATA is deprecated. 上面的方法是首选方法,因为不建议使用$ HTTP_RAW_POST_DATA。

The data can then be parsed using the PHP unpack() function. 然后可以使用PHP unpack()函数解析数据。

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

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