【发布时间】:2017-01-24 19:23:39
【问题描述】:
我是 php 新手。目前我可以看代码(不好),可以写一点。
我有几个体重秤。 从第一个我可以用这个脚本读取重量:
// host and port to connect to
$host = "10.0.0.119";
$port = 3400;
// connect to the port
$fp = fsockopen($host, $port, $errno, $errstr);
// don't die
set_time_limit(0);
// if connection not successfull, display error
if (!$fp)
{
die("no connection");
}
else
{
// connection successfull, listen for data (1024 bytes by default)
$got = fgets($fp);
// display the data
echo $got;
}
fclose($fp);
这是套接字监听器的输出:
这是来自浏览器:
但从其他比例来看,我什么也看不懂。 这是socket终端的输出:(见图3)
我认为问题出在 php 脚本中,但我找不到。如果有人可以帮助我,我会很高兴。
【问题讨论】:
-
现在我用这个来解决这个问题:` ini_set("auto_detect_line_endings", true); `