title: How to read all the information of a request and to reuse them to make another request?
body: <p>I have a PHP page that calls another page and I'd like to transfer all the information / headers of the original request to that call.</p>
  <p>I found <code>file_get_contents</code> to make the request and build the http request context with <code>stream_context_create</code>.</p>
  <p>I found <code>getallheaders</code> and <code>get_headers</code> but not sure of the difference. I am also aware of <code>$_REQUEST</code> to get the request information.</p>
  <p>Is there a straightforward way to get the information of the original request that will work in <code>stream_context_create</code> directly to make the new request?</p>
  <pre><code># Parse the request
  $method = ...
  $headers = ...
  # something else? cookie / IP?
  
  # Build the request reusing the information from the original request
  $opts = [
      &quot;http&quot; =&gt; [
          &quot;method&quot; =&gt; $method,
          &quot;header&quot; =&gt; $headers
      ]
  ];
  $context = stream_context_create($opts);
  $text = file_get_contents($url, false, $context);
  </code></pre>