开发者

Perl CTRL-D equivalent in PHP?

开发者 https://www.devze.com 2023-02-20 01:35 出处:网络
I\'m trying to represent the following Perl line in PHP: $msg=\"!<connect_nettapi>\\cD\";# Message ends with CTRL+D

I'm trying to represent the following Perl line in PHP:

$msg="!<connect_nettapi>\cD";  # Message ends with CTRL+D
开发者_C百科

I'm sending this string over a socket and the receiving API requires that the command be terminated by the CTRL+D character. I've been trying to use:

$msg="!<connect_nettapi>" . chr(some_hex_code);  # Message ends with CTRL+D

Thanks in advance.


It's the EOT character (end of transmission). It's ASCII value is 4.


If you want to skip the call to chr you can use a hex escape in your string

$msg="!<connect_nettapi>\x04";  # Message ends with CTRL-D (hex 04)
0

精彩评论

暂无评论...
验证码 换一张
取 消