CURL and access a site remotely

if you want to access a file from another server, you can use,

file_get_contents, file, fopen etc

but they are disabled on certain servers. so we should always
use curl to remotely access a file, or to remotely login a site,
CURL work as a hidden browser.

Here is a sample code to get content from google

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_URL, “”);
$content = curl_exec ( $ch );
echo $content;

this is a simple example, you can use CURL for more complex works. I’ll write here
another CURL advanced example soon.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.