使用php 封装一个get请求循环函数 httpatql6pkbcominczhuceincphpuser=test123&mima=test123&name=E8BDA6E88AB1E58FB6&qu=1&bm=&_=1691834881737 把user 和 name单独封装请求 name使用URL编码提交
您可以使用以下代码来封装一个GET请求循环函数:
function sendGetRequest($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
$user = 'test123';
$name = urlencode('车花叶');
$userUrl = "http://atql.6pkb.com/inc/zhuce.inc.php?user=$user";
$nameUrl = "http://atql.6pkb.com/inc/zhuce.inc.php?name=$name";
$userResponse = sendGetRequest($userUrl);
$nameResponse = sendGetRequest($nameUrl);
// 处理$userResponse和$nameResponse的逻辑
在上面的代码中,sendGetRequest函数封装了发送GET请求的逻辑。您可以将需要发送的URL作为参数传递给该函数,并获取返回的响应数据。
然后,您可以使用urlencode函数对name进行URL编码,以确保特殊字符正确地传递给服务器。
最后,通过调用sendGetRequest函数分别发送user和name的请求,并获取响应数据进行后续处理
原文地址: https://www.cveoy.top/t/topic/iBIp 著作权归作者所有。请勿转载和采集!