You are here
php curl request Basic PHP PHP PHP Coding 

PHP cURL Requests

PHP cURL Requests

PHP cURL Requests :  A simple introduction to GET and POST requests over HTTP.

The idea behind the cURL functions is to initialize a cURL session using the cURL_init(), then  set all your options for the transfer via the cURL_setopt(), then execute the session with the cURL_exec() and then  finish off the session using the cURL_close().

Example of cURL functions to fetch the homepage into a file:


$ch = cURL_init("");
$fp = fopen("example_homepage.txt", "w");

cURL_setopt($ch, cURLOPT_FILE, $fp);
cURL_setopt($ch, cURLOPT_HEADER, 0);



All cURL Functions :

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 : Returns a new cURL multi handle
cURL_multi_remove_handle : Remove a multi handle from a set of cURL handles
cURL_multi_select : Get all the sockets associated with the cURL extension, which can then be “selected”
cURL_setopt_array : Set multiple options for a cURL transfer
cURL_setopt : Set an option for a cURL transfer
cURL_version : Return the current cURL version




Related posts

Leave a Comment