Skip to content

Instantly share code, notes, and snippets.

@marshluca
Created February 12, 2011 09:58
Show Gist options
  • Save marshluca/823658 to your computer and use it in GitHub Desktop.
Save marshluca/823658 to your computer and use it in GitHub Desktop.
call url in php
1.apt-get install php5-curl
2./etc/init.d/apache2 restart
3.curl.php:
<?
$ch = curl_init();
$timeout = 5;
curl_setopt ($ch, CURLOPT_URL, 'http://www.baidu.com/');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
echo $file_contents;
?>
apache 启用 rewrite 模块:sudo a2enmod rewrite
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment