mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 08:58:56 +00:00
Added a couple examples.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@102832 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
124b7f5e32
commit
aaf30477a2
1 changed files with 37 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.8 $ -->
|
||||
<!-- $Revision: 1.9 $ -->
|
||||
<!-- splitted from ./en/functions/http.xml, last change in rev 1.7 -->
|
||||
<refentry id="function.headers-sent">
|
||||
<refnamediv>
|
||||
|
@ -34,8 +34,42 @@
|
|||
</simpara>
|
||||
</note>
|
||||
<para>
|
||||
See also <function>ob_start</function> and <function>header</function> for a
|
||||
more detailed discussion of the matters involved.
|
||||
<example>
|
||||
<title>Examples using <function>headers_sent</function></title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
// If no headers are sent, send one
|
||||
if (!headers_sent()) {
|
||||
header ('Location: http://www.example.com/');
|
||||
exit;
|
||||
}
|
||||
|
||||
// An example using the optional file and line parameters, as of PHP 4.3.0
|
||||
// Note that $filename and $linenum are passed in for later use.
|
||||
// Do not assign them values beforehand.
|
||||
if (!headers_sent($filename, $linenum)) {
|
||||
header ('Location: http://www.example.com/');
|
||||
exit;
|
||||
|
||||
// You would most likely trigger an error here.
|
||||
} else {
|
||||
|
||||
print "Headers already sent in $filename on line $linenum\n";
|
||||
print "Cannot redirect, for now please click this $link instead\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
See also <function>ob_start</function>, <function>trigger_error</function>,
|
||||
and <function>header</function> for a more detailed discussion of the
|
||||
matters involved.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
|
Loading…
Reference in a new issue