mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
add example on how to send POST data using stream context opts. many thanks to Sara for the code
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@218006 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
714608859f
commit
6b8f6fedcd
1 changed files with 30 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.61 $ -->
|
||||
<!-- $Revision: 1.62 $ -->
|
||||
<appendix id="wrappers">
|
||||
<title>List of Supported Protocols/Wrappers</title>
|
||||
<para>
|
||||
|
@ -202,6 +202,35 @@ foreach($meta_data['wrapper_data'] as $response) {
|
|||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
<example>
|
||||
<title>Fetch a page and send POST data</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$postdata = http_build_query(
|
||||
array(
|
||||
'var1' => 'some content',
|
||||
'var2' => 'doh'
|
||||
)
|
||||
);
|
||||
|
||||
$opts = array('http' =>
|
||||
array(
|
||||
'method' => 'POST',
|
||||
'header' => 'Content-type: application/x-www-form-urlencoded',
|
||||
'content' => $postdata
|
||||
)
|
||||
);
|
||||
|
||||
$context = stream_context_create($opts);
|
||||
|
||||
$result = file_get_contents('http://example.com/submit.php', false, $context);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<simpara>
|
||||
The stream allows access to the <emphasis>body</emphasis> of
|
||||
the resource; the headers are stored in the
|
||||
|
|
Loading…
Reference in a new issue