Home > Backend Development > PHP Tutorial > PHP socket出现乱码解决方案

PHP socket出现乱码解决方案

WBOY
Release: 2016-06-13 13:32:12
Original
2455 people have browsed it

PHP socket出现乱码
PHP这边作为客户端发起连接请求,代码如下:

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);   
$connection = socket_connect($socket, '192.168.8.216', 2012); 
$buffer = @socket_read($socket, 1024, PHP_NORMAL_READ); 
var_dump($buffer);

Copy after login

结果打印出来的是string '??c' (length=5)。这是怎么回事?

------解决方案--------------------
前面4个可能是一个数

你和他通讯都不约定的吗?
------解决方案--------------------
你还是用fsockopen吧
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template