svn: /phpdoc/en/trunk/reference/network/functions/ header-register-callback.xml
| From: | Hannes Magnusson | Date: | Wed, 06 Jul 2011 21:22:42 +0000 |
| Subject: | svn: /phpdoc/en/trunk/reference/network/functions/ header-register-callback.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-8441@lists.php.net to get a copy of this message | ||
bjori Wed, 06 Jul 2011 21:22:42 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=313027
Log:
Improve doc and and scotts usage example
Changed paths:
U phpdoc/en/trunk/reference/network/functions/header-register-callback.xml
Modified: phpdoc/en/trunk/reference/network/functions/header-register-callback.xml
===================================================================
--- phpdoc/en/trunk/reference/network/functions/header-register-callback.xml 2011-07-06 20:38:58 UTC
(rev 313026)
+++ phpdoc/en/trunk/reference/network/functions/header-register-callback.xml 2011-07-06 21:22:42 UTC
(rev 313027)
@@ -14,11 +14,13 @@
<methodparam><type>callback</type><parameter>callback</parameter></methodparam>
</methodsynopsis>
<para>
-
+ Registers a function that will be called when PHP starts sending output.
</para>
-
- &warn.undocumented.func;
-
+ <para>
+ The <parameter>callback</parameter> is executed just after PHP prepares all
+ headers to be sent, and before any other output is sent, creating a window
+ to manipulate the outgoing headers before being sent.
+ </para>
</refsect1>
<refsect1 role="parameters">
@@ -43,11 +45,61 @@
</para>
</refsect1>
+ <refsect1 role="examples">
+ &reftitle.examples;
+ <example xml:id="header-register-callback.example.basic">
+ <title><function>header_register_callback</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+header('Content-Type: text/plain');
+header('X-Test: foo');
+
+function foo() {
+ foreach (headers_list() as $header) {
+ if (strpos($header, 'X-Powered') !== false) {
+ header_remove('X-Powered-By');
+ }
+ header_remove('X-Test');
+ }
+}
+
+$result = header_register_callback('foo');
+echo "a";
+?>
+]]>
+ </programlisting>
+ &example.outputs.similar;
+ <screen>
+<![CDATA[
+Content-Type: text/plain
+
+a
+]]>
+ </screen>
+ </example>
+ </refsect1>
+
<refsect1 role="notes">
&reftitle.notes;
+ <para>
+ <function>header_register_callback</function> is executed just as the
+ headers are about to be sent out, so any output from this function can
+ break output.
+ </para>
¬e.network.header.sapi;
</refsect1>
+ <refsect1 role="seealso">
+ &reftitle.seealso;
+ <simplelist>
+ <member><function>headers_list</function></member>
+ <member><function>header_remove</function></member>
+ <member><function>header</function></member>
+ </simplelist>
+ </refsect1>
+
</refentry>
<!-- Keep this comment at the end of the file