Problem with url parameters when php uses curl to initiate get request

PHP中文网
Release: 2023-03-01 08:34:01
Original
4181 people have browsed it

The problem with the url parameters when PHP uses curl to initiate a get request:

When sending a get request, can the url not have a query string, but can only be the domain name + path? My example is as follows. Does it not work after adding the query string? ? ?

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.dest.cn/member/my.php");
//curl_setopt($ch, CURLOPT_URL, "http://www.dest.cn/member/my.php?mid=14&my_calfee=1")
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$kk = curl_exec($ch);
curl_close($ch);
print_r($kk);
Copy after login
Copy after login

Reply content:

When sending a get request, can the URL not contain a query string, but can only be a domain name + path? My example is as follows. Does it not work after adding the query string? ? ?

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.dest.cn/member/my.php");
//curl_setopt($ch, CURLOPT_URL, "http://www.dest.cn/member/my.php?mid=14&my_calfee=1")
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$kk = curl_exec($ch);
curl_close($ch);
print_r($kk);
Copy after login
Copy after login

Get is url parameter passing

The above is the content of the url parameter problem when PHP uses curl to initiate a get request. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

Related articles:

Using curl to send requests (GET requests and POST requests) in PHP

Detailed examples of precautions for using curl function to send Post requests in PHP

PHP development skills (8) - CURL Requested code details

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template