Home  >  Article  >  Backend Development  >  Problem with url parameters when php uses curl to initiate get request

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

PHP中文网
PHP中文网Original
2017-03-22 10:20:444167browse

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);

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);

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

Statement:
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