Skip to content

Instantly share code, notes, and snippets.

@libo1106
Last active December 21, 2015 07:08
Show Gist options
  • Save libo1106/6268515 to your computer and use it in GitHub Desktop.
Save libo1106/6268515 to your computer and use it in GitHub Desktop.
proxy for file_get_contents()
<?php
$proxy = stream_context_create(array(
'http' => array(
'timeout' => 5,
'proxy' => 'tcp://proxy.domain.com:8080',
'request_fulluri' => True,
)
));
$page = file_get_contents('http://www.baidu.com/', false, $proxy);
echo($page);
//能不能上网?百度一下
// 如要要支持HTTPS协议,还得修改php和apache的配置文件。
// 打开php.ini找到 ;extension=php_openssl.dll ,去掉前面的分好
// 重启httpd服务
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment