php coder pro 调试,开发自己的API调试器(php版本)

这个博客展示了如何使用PHP创建一个调试器类`hcCurl`,该类用于执行GET和POST请求,并能获取HTTP状态码和响应速度。通过设置curl选项,如忽略SSL验证和设置超时时间,它能够处理压缩编码的响应。此外,博客还提供了一个简单的表单,允许用户输入URL和POST数据来模拟HTTP POST请求。
摘要由CSDN通过智能技术生成

php版调试器代码<?php

class hcCurl {

public $httpStatus;

private $curlHndle;

public $speed;

public $timeOut = 20;

public function __construct(){$this->curlHandle = curl_init();}

public function get($url){

curl_setopt($this->curlHandle, CURLOPT_URL , $url);

curl_setopt($this->curlHandle, CURLOPT_RETURNTRANSFER , true);

curl_setopt($this->curlHandle, CURLOPT_SSL_VERIFYPEER , false);

curl_setopt($this->curlHandle, CURLOPT_SSL_VERIFYHOST , false);

curl_setopt($this->curlHandle, CURLOPT_ENCODING , 'gzip,deflate');

curl_setopt($this->curlHandle, CURLOPT_TIMEOUT , $this->timeOut);

$result = curl_exec($this->curlHandle);

$this->http_status = curl_getinfo($this->curlHandle);

$this->speed = round($this->httpStatus['pretransfer_time']*1000, 2);

return $result;

}

public function post($url, $data){

curl_setopt($this->curlHandle, CURLOPT_POST, 1);

curl_setopt($this->curlHandle, CURLOPT_POSTFIELDS, $data);

return $this->get($url);

}

}

?>

post 模拟器

td{padding:5px;}

url :
data :

xx=xx&xx=xx

if(!empty($_POST['url'])){

$curl = new hcCurl();

$postData = $_POST['data'];

echo $curl->post($_POST['url'], $postData);

}

?>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值