|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40849 file_get_context context parameter doesn't work
Submitted: 2007-03-18 21:46 UTC Modified: 2007-03-19 21:16 UTC
From: djgrrr+phpbugs at p2p-network dot net Assigned:
Status: Not a bug Package: Streams related
PHP Version: 5.2.1 OS: Linux 2.6
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: djgrrr+phpbugs at p2p-network dot net
New email:
PHP Version: OS:


 [2007-03-18 21:46 UTC] djgrrr+phpbugs at p2p-network dot net
On windows it works fine, but, with *nix and possibly *bsd, the context parameter to file_get_contents does absolutely nothing, meaning you can't change the method, submit post data, change the bind ip, etc, with file_get_contents().

The example shown in the docs does not work

Reproduce code:

$postdata = http_build_query(
       'var1' => 'some content',
       'var2' => 'doh'

$opts = array('http' =>
       'method'  => 'POST',
       'header'  => 'Content-type: application/x-www-form-urlencoded',
       'content' => $postdata

$context  = stream_context_create($opts);

echo file_get_contents('', false, $context);


Expected result:
i expect the returned post array from this script to be populated, which it would be if you did an actually post query on

if you run this from windows, it works fine and shows up like this:
$_POST = array (
  'var1' => 'some content',
  'var2' => 'doh',

Actual result:
if you try the same code on *nix you get an empty post array:
$_POST = array (
and if you look at the $_SERVER array you can see that none of the context options did anything


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-19 09:23 UTC]
$_POST = array (
  'var1' => 'some content',
  'var2' => 'doh',

Cannot reproduce.
 [2007-03-19 21:11 UTC] djgrrr+phpbugs at p2p-network dot net
seems your right, sorry, i must have done something with my original testing :S
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC