philip          Wed Nov  6 20:29:44 2002 EDT

  Modified files:              
    /phpdoc/en/reference/http/functions headers-sent.xml 
  Log:
  Added a couple examples.
  
  
Index: phpdoc/en/reference/http/functions/headers-sent.xml
diff -u phpdoc/en/reference/http/functions/headers-sent.xml:1.8 
phpdoc/en/reference/http/functions/headers-sent.xml:1.9
--- phpdoc/en/reference/http/functions/headers-sent.xml:1.8     Wed Nov  6 17:10:40 
2002
+++ phpdoc/en/reference/http/functions/headers-sent.xml Wed Nov  6 20:29:44 2002
@@ -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>



-- 
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to