PHP curl not working in browser

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ks.sundarrajan
Forum Newbie
Posts: 1
Joined: Wed Dec 30, 2009 10:32 pm

PHP curl not working in browser

Post by ks.sundarrajan »

I have a situation here....
the below is a simple curl script in php:

Code: Select all

 
$curl = curl_init();
echo $curl;
curl_setopt ($curl, CURLOPT_URL, "http://php.net");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
echo curl_exec ($curl);
curl_close($curl); 
 
This works perfectly when i run it in a command line like this - php test.php
I get the desired output.

But, if i access test.php file from the browser, i do not get any output.
http://localhost/test/test.php

I saw the logs, but there is nothing in it.

Should i do any apache settings to run curl?

Thanks,
Sundar
Post Reply