mirror of
https://github.com/macintoshplus/doc-en.git
synced 2026-03-25 17:32:09 +01:00
Two & 1/2 things with the PHP example code: 1. `X-` prefix header names June 2012 [1], [2]. 2. PHP prepends the `default_charset` [3] on any `text/*` media type in Content-Type header, unless the `charset` is with the `header()` call, like in the example. 3. PHP version 5.1.3 (May 2006) -> 8.0.11, the X-Powered-By header [4] removed (only distracting w/ the example). PHP version in use to generate the output: 8.0.11. [1]: https://datatracker.ietf.org/doc/html/rfc6648 [2]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers [3]: https://www.php.net/manual/en/ini.core.php#ini.default-charset [4]: https://www.php.net/manual/en/ini.core.php#ini.expose-php Co-authored-by: Tiffany <tiffany.k.taylor@gmail.com>
117 lines
2.7 KiB
XML
117 lines
2.7 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<refentry xml:id="function.headers-list" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>headers_list</refname>
|
|
<refpurpose>Returns a list of response headers sent (or ready to send)</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>headers_list</methodname>
|
|
<void/>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>headers_list</function> will return a list of headers to be sent
|
|
to the browser / client. To determine whether or not these headers have
|
|
been sent yet, use <function>headers_sent</function>.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
&no.function.parameters;
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Returns a numerically indexed array of headers.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Example using <function>headers_list</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
/* setcookie() will add a response header on its own */
|
|
setcookie('foo', 'bar');
|
|
|
|
/* Define a custom response header
|
|
This will be ignored by most clients */
|
|
header("Example-Test: foo");
|
|
|
|
/* Specify plain text content in our response */
|
|
header('Content-Type: text/plain; charset=UTF-8');
|
|
|
|
/* What headers are going to be sent? */
|
|
var_dump(headers_list());
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.similar;
|
|
<screen>
|
|
<![CDATA[
|
|
array(3) {
|
|
[0]=>
|
|
string(19) "Set-Cookie: foo=bar"
|
|
[1]=>
|
|
string(17) "Example-Test: foo"
|
|
[2]=>
|
|
string(39) "Content-Type: text/plain; charset=UTF-8"
|
|
}
|
|
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
¬e.network.header.sapi;
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>headers_sent</function></member>
|
|
<member><function>header</function></member>
|
|
<member><function>setcookie</function></member>
|
|
<member><function>apache_response_headers</function></member>
|
|
<member><function>http_response_code</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|