The functions used are curl_init, curl_setopt, curl_exec, curl_close.
The default is GET method, you can choose whether to use Header:
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "$url"); curl_setopt($ch, CURLOPT_TIMEOUT, 2); curl_setopt($ch, CURLOPT_HEADER, 1); //如果设为0,则不使用header curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); $result = curl_exec($ch); curl_close($ch);
POST method:
$ch = curl_init(); curl_setopt($ch,CURLOPT_URL,'$url'); curl_setopt($ch,CURLOPT_POST,1); curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE); $vars =sprintf('from=%d&to=%d&subject=%s&body=%s',$from, $to, urlencode($subject), urlencode($body)); curl_setopt($ch,CURLOPT_POSTFIELDS,$vars); $ret = curl_exec($ch); curl_close($ch);
HTTP requests include POST and GET. When writing a form, you can specify the action as post or get. The array $_POST stores the variables passed by the POST method, and $_GET stores the variables passed by the GET method. $_REQUEST contains both.
For example
It depends on whether your submission method is GET or POST. Generally, form submission has a method specified, and $_GET is used to retrieve the information passed in the address bar, such as: www.tbsoo.com/cases.htm?s=&page=4 where the page is Use GET to get it. If your PAGE is submitted from the form, then use $_REQUEST, or write a judgment. If you cannot get it with GET, use POST, but it is most convenient to use REQUEST