pollita Fri Aug 15 11:16:32 2003 EDT
Modified files:
/phpdoc/en/appendices wrappers.xml
Log:
Incorporate user note re: following redirects.
Index: phpdoc/en/appendices/wrappers.xml
diff -u phpdoc/en/appendices/wrappers.xml:1.23 phpdoc/en/appendices/wrappers.xml:1.24
--- phpdoc/en/appendices/wrappers.xml:1.23 Mon Jul 21 23:38:06 2003
+++ phpdoc/en/appendices/wrappers.xml Fri Aug 15 11:16:32 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.23 $ -->
+<!-- $Revision: 1.24 $ -->
<appendix id="wrappers">
<title>List of Supported Protocols/Wrappers</title>
<para>
@@ -32,8 +32,35 @@
<simpara>
Redirects have been supported since PHP 4.0.5; if you are using
an earlier version you will need to include trailing slashes in
- your URLs.
+ your URLs. If it's important to know the url of the resource where
+ your document came from (after all redirects have been processed),
+ you'll need to process the series of response headers returned by the
+ stream.
</simpara>
+ <informalexample>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$url = 'http://www.example.com/redirecting_page.php';
+
+$fp = fopen($url, 'r');
+
+/* Prior to PHP 4.3.0 use $http_response_header
+ instead of stream_get_meta_data() */
+foreach(stream_get_meta_data($fp) as $response) {
+
+ /* Were we redirected? */
+ if (substr(strtolower($response), 0, 10) == 'location: ') {
+ /* update $url with where we were redirected to */
+ $url = substr($response, 10);
+ }
+
+}
+
+?>
+]]>
+ </programlisting>
+ </informalexample>
<simpara>
The stream allows access to the <emphasis>body</emphasis> of
the resource; the headers are stored in the
--
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php