Home > Backend Development > PHP Tutorial > php curl usage

php curl usage

高洛峰
Release: 2016-11-29 16:10:37
Original
1037 people have browsed it

When using curl in php, you must first open extension=php_curl.dll in php.ini; then go there. Curl is a built-in browser in php. It can imitate user browsing information for website browsing. Wait for the following Let’s look at an example. The code is as follows:

function postpage($url)

{

$response = "";

$rd=rand(1,4);

$proxy='http://221.214 .27.253:808';

if($rd==2) $proxy='http://222.77.14.56:8088';

if($rd==3) $proxy='http://202.98 .123.126:8080';

if($rd==4) $proxy='http://60.14.97.38:8080';

if($url != "") {

$ch = curl_init( $url);

curl_setopt($ch, curlopt_header, 0);

curl_setopt($ch, curlopt_returntransfer, true);

curl_setopt($ch, curlopt_proxy, $proxy);

$response = curl_exec($ch ;

curl_close — close a curl session

curl_copy_handle — copy a curl handle along with all of its preferences

curl_errno — return the last error number

curl_error — return a string containing the last error for the current session

curl_exec — perform a curl session

curl_getinfo — get information regarding a specific transfer

curl_init — initialize a curl session

curl_multi_add_handle — add a normal curl handle to a curl multi handle

curl_multi_close — close a set of curl handles

curl_multi_exec — run the sub-connections of the current curl handle

curl_multi_getcontent — return the content of a curl handle if curlopt_returntransfer is set

curl_multi_info_read — get information about the current transfers

curl_multi_init — re turns a new curl multi handle

curl_multi_remove_handle — remove a multi handle from a set of curl handles

curl_multi_select — wait for activity on any curl_multi connection

curl_setopt_array — set multiple options for a curl transfer

curl_setopt — set an option for a curl transfer

curl_version — gets curl version information

Related labels:
php
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