Using HTTP proxies in PHP

Can you give me an example of using an HTTP proxy in PHP?

+3
source share
1 answer

If you want to use PHP to request HTTP through a proxy server, you can use the proxy option .

Example:

$opts = array('http' =>
    array(
        'proxy'  => 'tcp://proxy.example.com:5100',
    )
);

$context  = stream_context_create($opts);
$result = file_get_contents('http://example.com/somefile.html', false, $context);
+3
source

Source: https://habr.com/ru/post/1759767/


All Articles