Curl Example in PHP

Here is a sample script to use curl and check the output. You can use this script in your local server and if curl is installed then you will get simple output message from this website.

<?Php
$my_curl = curl_init();
$str="John"; // Change to your name

curl_setopt($my_curl, CURLOPT_URL, "http://www.plus2net.com/php_tutorial/curl-test.php?str=$str");

curl_setopt($my_curl, CURLOPT_RETURNTRANSFER, 1);

$return_str = curl_exec($my_curl);

curl_close($my_curl);

echo $return_str;
?>

Opening a URL by file_get_contents()

Subscribe to our mailing list

* indicates required
Subscribe to plus2net
Visitors Rating
Your Rating


Google+

Post Comment This is for short comments only. Use the forum for more discussions.




Subscribe to our mailing list

* indicates required
Subscribe to plus2net
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us
©2000-2017 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer