PHP接口并发测试的方法(推荐)

如下所示:

header('Content-type:text/html; Charset=utf-8');

      $uri = "输入你的url";

      $data = array(
        'test'=>1
      );
      $ch = curl_init();
// print_r($ch);
      curl_setopt($ch, CURLOPT_URL, $uri);
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_HEADER, 0);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
      $return = curl_exec($ch);
      curl_close($ch);

然后用ab小工具测试

相关推荐