我如何通过一个PHP插座发送二进制重新presentation? [英] How do I send the binary representation through a PHP socket?
本文介绍了我如何通过一个PHP插座发送二进制重新presentation?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过一个PHP插座发送数据的二进制重新presentation。
I'm trying to send the binary representation of data through a PHP socket.
因此,如果数量为15, socket_write
将派遣00001111二进制重新presentation为15.
So if the number was 15, socket_write
would send 00001111 as binary representation for 15.
我应该怎么做呢?
推荐答案
使用 CHR
功能:
socket_write( $fp, chr(15));
您也可以使用 \\ X
十六进制转义值:
You can also use \x
escapes with hex values:
socket_write( $fp, "\xff\xff\xff\xff" );
会在每次发送4个字节,其值255。
Would send 4 bytes, with values 255 on each.
这篇关于我如何通过一个PHP插座发送二进制重新presentation?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文