Last active
December 21, 2015 07:08
-
-
Save libo1106/6268515 to your computer and use it in GitHub Desktop.
proxy for file_get_contents()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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