Last active
October 27, 2022 12:10
-
-
Save tdebatty/ef01b99139dd52d2a0bcdd24120c5e00 to your computer and use it in GitHub Desktop.
file_get_contents with proxy support
This file contains 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 | |
$context = array(); | |
$proxy = getenv("http_proxy"); | |
if ($proxy !== null) { | |
$context['http'] = array( | |
'proxy' => str_replace("http", "tcp", $proxy), | |
'request_fulluri' => true | |
); | |
} | |
$cxContext = stream_context_create($context); | |
file_get_contents($file, false, $cxContext); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment