Skip to content

Instantly share code, notes, and snippets.

@shameerc
Created December 21, 2010 10:36
Show Gist options
  • Select an option

  • Save shameerc/749769 to your computer and use it in GitHub Desktop.

Select an option

Save shameerc/749769 to your computer and use it in GitHub Desktop.
Post using streams
<?php
$data = array ('name' => 'hello', 'email' => 'hello@hello.com');
$data = http_build_query($data);
$context_options = array (
'http' => array (
'method' => 'POST',
'header'=> "Content-type: application/x-www-form-urlencoded\r\n"
. "Content-Length: " . strlen($data) . "\r\n",
'content' => $data
)
);
$context = stream_context_create($context_options);
$fp = fopen('http://localhost/abc.php', 'r', false, $context);
$var = stream_get_contents($fp);
print_r($var);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment