PHP curl example

1. Initialize the curl by curl_init()
2. set the options by curl_setopt
3. curl_exec to get the result
4. Do whatever you like with the result. As an example, this code snippet decode the the json object and var dump it.

<?php
$url = "http://itools.codexpedia.com/demo/php-curl-example/getEmployees.php";
//  Initiate curl
$ch = curl_init();
// Disable SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL,$url);
// Execute
$results=curl_exec($ch);
$results=json_decode($results, true);

var_dump($results);

demo

Search within Codexpedia

Custom Search

Search the entire web

Custom Search