php语言得用fsockopen()函数,实现脚本异步运行,代码如下
//异步请求函数(用debug参数若为true则为用为调试,开启调试可以看到异步的执行情况,但是失去异步的效果)
main.php
$v){
$_post[]= $k."=".urlencode($v);//必须做url转码以防模拟post提交的数据中有&符而导致post参数键值对紊乱
}
$_post = implode('&', $_post);
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";//POST数据
$header .= "Content-Length: ". strlen($_post) ."\r\n";//POST数据的长度
$header.="Connection: Close\r\n\r\n";//长连接关闭
$header .= $_post; //传递POST数据
}else{
$header.="Connection: Close\r\n\r\n";//长连接关闭
}
fwrite($fp, $header);
//-----------------调试代码区间-----------------
//注如果开启下面的注释,异步将不生效可是方便调试
if($debug){
$html = '';
while (!feof($fp)) {
$html.=fgets($fp);
}
echo $html;
}
//-----------------调试代码区间-----------------
fclose($fp);
}
$data=array('name'=>'guoyu','pwd'=>'123456');
$url='http://localhost/test/other.php';
request_by_fsockopen($url,$data,true);//
other.php
使用实例:
[运行的main.php主脚本文件]
$data=array('name'=>'guoyu','pwd'=>'123456');
$url='http://localhost/test/other.php';
request_by_fsockopen($url,$data,true);//把应用B的用户表异步-同步数据
[导步执行文件other.php]
在other.php中便可以用$_POST接收main.php提交过来的参数,采集软件,从而进行下一步操作
相关报道:
1.scalesPageToFit设置为YES,这样web页面会根据屏幕大小进行自动缩放。 2.UIWebView的状态监视 //内容读入开始前被调用。将UIWebView,返回no后UIWebView不进行读入处理。如果想在单击链接时进行独自处理则处理 - (BOOL)webView:(UIWebView *)webView shoul 更多
接触到地产类网站有三年时间了,之前一直是在做医疗行业。地产类网站目前来说可谓是市场火热,前途一片光明。首先地产分为房地产、商业地产、工业地产、旅游地产以及现在只有少部分人知道的产业地产。而我选择的工业地产,也就是前两年时间地产行业绝对的大 更多