- <?php
- //异步请求
- $host = "localhost";
- $path = '4.php';
- $port = 80;
- $data = "['email'=>'email@163.com','name'=>'xiaoming']";
- $param = http_build_query($data);
- $fp = fsockopen($host,$port,$errno,$errstr,30);
- if($fp)
- {
- //post 请求
- $header = "POST $path HTTP/1.0\r\n";
- $header .= 'Host:'.$host."\r\n";
- $header .= "Content-Type:application/x-www-form-urlencoded\r\n";
- $header .="Content-Length:".strlen($param)."\r\n";
- $header .= 'Connection:Close'."\r\n\r\n";
- $header .= $param;
- fputs($fp, $header);
- fclose($fp);
- //get请求
- /*
- $path = $path.'?'.$param;
- $header = "GET $path HTTP/1.0\r\n";
- $header .= 'Host:'.$host."\r\n";
- $header .= 'Connection:Close'."\r\n\r\n";
- fputs($fp, $header);
- fclose($fp);
- */
- }
- else
- {
- echo $error.'__'.$errstr;
- exit;
- }
- echo 'send ok!';
- ?>
复制代码- <?php
- set_time_limit ( 0 );
- ignore_user_abort ( true );
- $i = 0;
- while ( $i ++ < 3 ) {
- file_put_contents($i.'.txt',$_REQUEST['email']);
- sleep ( 3 );
- }
- ?>
复制代码
|