nlopess Fri Aug 11 22:00:05 2006 UTC
Modified files:
/phpdoc/en/appendices wrappers.xml
Log:
add example on how to send POST data using stream context opts. many thanks
to Sara for the code
http://cvs.php.net/viewvc.cgi/phpdoc/en/appendices/wrappers.xml?r1=1.61&r2=1.62&diff_format=u
Index: phpdoc/en/appendices/wrappers.xml
diff -u phpdoc/en/appendices/wrappers.xml:1.61
phpdoc/en/appendices/wrappers.xml:1.62
--- phpdoc/en/appendices/wrappers.xml:1.61 Sun May 28 20:33:19 2006
+++ phpdoc/en/appendices/wrappers.xml Fri Aug 11 22:00:05 2006
@@ -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 @@
]]>
</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