A
Anonymous
Guest
Hey all,
Was trying to understand the concepts behind PHP programming. Was behind cURL trying to connect a URL. Just curious and wanted to understand if this how it's done. Ref - https://www.interviewbit.com/php-interview-questions/
Was trying to understand the concepts behind PHP programming. Was behind cURL trying to connect a URL. Just curious and wanted to understand if this how it's done. Ref - https://www.interviewbit.com/php-interview-questions/
Code:
//Step 1 To initialize curl
$ch = curl_init();
//Step 2 To set url where you want to post
$url = ‘http://www.localhost.com’;
//Step 3 Set curl functions which are needs to you
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_POSTFIELD,’postv1 = value1&postv2 = value2’);
//Step 4 To execute the curl
$result = curl_exec($ch);
//Step 5 Close curl
curl_close($ch);