Showing posts with label curl simple examples. Show all posts
Showing posts with label curl simple examples. Show all posts
cURL Simple Example in PHP
Posted by Raj
cURL Simple Example in PHP:
cURL allows you to connect and communicate to many different types of servers with many different types of protocols.
PHP Supports libcurl.
Example:
<?php
// initialize curl session
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "example.com"); // set url
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//return the transfer as a string
$output = curl_exec($ch);//output string
// close curl session
curl_close($ch);
?>
cURL allows you to connect and communicate to many different types of servers with many different types of protocols.
PHP Supports libcurl.
Example:
<?php
// initialize curl session
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "example.com"); // set url
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//return the transfer as a string
$output = curl_exec($ch);//output string
// close curl session
curl_close($ch);
?>
What is cURL in PHP?
Posted by Raj
What is cURL in PHP?
cURL allows you to connect and communicate to many different types of servers with many different types of protocols.
PHP Supports libcurl.
Requirements:
In order to use PHP's cURL functions you need to install the libcurl package.PHP 5.0.0 requires a libcurl version 7.10.5 or greater.
cURL Functions:
curl_close : Close a cURL session.
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_setopt_array: Set multiple options for a cURL transfer.
curl_setopt: Set an option for a cURL transfer.
curl_version: Gets cURL version information.
cURL allows you to connect and communicate to many different types of servers with many different types of protocols.
PHP Supports libcurl.
Requirements:
In order to use PHP's cURL functions you need to install the libcurl package.PHP 5.0.0 requires a libcurl version 7.10.5 or greater.
cURL Functions:
curl_close : Close a cURL session.
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_setopt_array: Set multiple options for a cURL transfer.
curl_setopt: Set an option for a cURL transfer.
curl_version: Gets cURL version information.