Using get_headers and file_get_contents PHP functions behind Proxy

You can use get_headers and file_get_contents PHP functions behind proxy, using stream_context_set_default function.

stream_context_set_default

resource stream_context_set_default ( array $options )
This function is used to set the default stream context which will be used whenever file operations (fopen, file_get_contents, etc...) are called without a context parameter. Uses the same syntax as stream_context_create.
Here is the code to use get_headers, file_get_contents and similar functions behind proxy:
<?php
// Edit the four values below
$PROXY_HOST = "proxy.example.com"; // Proxy server address
$PROXY_PORT = "1234";    // Proxy server port
$PROXY_USER = "LOGIN";    // Username
$PROXY_PASS = "PASSWORD";   // Password
// Username and Password are required only if your proxy server needs basic authentication

$auth = base64_encode("$PROXY_USER:$PROXY_PASS");
stream_context_set_default(
 array(
  'http' => array(
   'proxy' => "tcp://$PROXY_HOST:$PROXY_PORT",
   'request_fulluri' => true,
   'header' => "Proxy-Authorization: Basic $auth"
   // Remove the 'header' option if proxy authentication is not required
  )
 )
);

$url = "http://www.pirob.com/";

print_r( get_headers($url) );

echo file_get_contents($url);
?>
Don't forget to replace the PROXY_ variables with appropriate values.