i use xampp apache to run some of my php files.
In one of my php file i use curl to get data from external website, on my windows machine, everything works fine. However, on my mac machine, my browser just can not run those files.. it just takes very long to load, and in the end stop loading.
Attached is one of my php file:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,
'http://www.example.com');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$contents = curl_exec ($ch);
curl_close ($ch);
print $contents;
?>
I am really desprate on why mac machine can not run these files? is there another way to go about doing this on a mac machine? THanks all for your help!
EDIT: [SOLVED] Thanks all for your help. Manage to solve it, due, to because i am connecting to the net using a proxy server…thus my script need to handle that.
Code used:
<?php
$aContext = array(
'http' => array(
'proxy' =>'tcp://xxxxx:xx',
'request_fulluri' => true,
),
);
$cxContext = stream_context_create($aContext);
$content = file_get_contents("http://www.example.com", False, $csContext);
print $content;
?>
use
echo file_get_contents('http://www.example.com');