RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
php网页接收无线数据 php访问网页发起post请求

PHP如何接收动态数据保存并实时显示到网页上?

头部加上超时控制,但对于很多服务器无效,因为服务器输出超时很多在服务器控制,所以建议用cmd脚本方式运行此程序:

青神网站建设公司成都创新互联,青神网站设计制作,有大型网站制作公司丰富经验。已为青神上千余家提供企业网站建设服务。企业网站搭建\成都外贸网站建设公司要多少钱,请找那个售后服务好的青神做网站的公司定做!

?php

set_time_limit(0); //禁用脚本超时

// Create the socket and connect

$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);

$connection = socket_connect($socket,'116。236。128。220', 14580);

// Write some test data to our socket

if(!socket_write($socket, "user NoCall pass -1 vers test 1.0 filter b/B* \r\n"))

{

echo("pWrite failed/p");

}

if(!file_exists('socket_log.html')){

file_put_contents('socket_log.html', 'script

var xx = setInterval(function(){ //每5秒刷新一次页面

window.location.reload();

}, 5000);

/script');

}

// Read any response from the socket

while($buffer = socket_read($socket, 64, PHP_NORMAL_READ))

{

echo json_encode($buffer); //转换为json数据输出

//记入文件

file_put_contents('socket_log.html', json_encode($buffer), FILE_APPEND);

}

echo("pDone Reading from Socket/p");

使用方法:用命令行方式运行此脚本

php script.php

脚本会一直运行到接收数据结束,并持续将收到的数据写入socket_log.html文件。

在浏览器打开socket_log.html页面,此页面会自动每5秒刷新一次,来显示最新的数据。

确保程序有权限创建及写入socket_log.html文件

PHP怎么接收数据

三中接受方式:

$_GET    //get过来的数据

$_POST  //post过来的数据

file_get_contents("php://input")   //接口过来的xml等字符串数据用这个接

这三个方法足以接受任何数据了,具体你还要百度一下用法

php怎样接收输入的数据

1.html

内容:

html

head

/head

body

form action="2.php" method="post"

input type="text" name="user" /

input type="submit" value="提交"

/form

/body

/html

2.php

内容:

echo $_POST['user'];

可以用get传,但是相对于的php页面也要用$_GET 接收。


当前文章:php网页接收无线数据 php访问网页发起post请求
网站路径:http://cqwzjz.cn/article/doegggg.html