downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/fr/function.headers-sent.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/ref.network.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'fr',
  ),
 
'this' =>
  array (
   
0 => 'function.headers-sent.php',
   
1 => 'headers_sent',
  ),
 
'up' =>
  array (
   
0 => 'ref.network.php',
   
1 => 'Fonctions réseaux',
  ),
 
'prev' =>
  array (
   
0 => 'function.headers-list.php',
   
1 => 'headers_list',
  ),
 
'next' =>
  array (
   
0 => 'function.inet-ntop.php',
   
1 => 'inet_ntop',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="function.headers-sent" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">headers_sent</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">headers_sent</span> &mdash; <span class="dc-title">Indique si les en-têtes HTTP ont déjà été envoyés</span></p>

 </div>

 <a name="function.headers-sent.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><b>headers_sent</b></span>
    ([ <span class="methodparam"><span class="type">string</span> <tt class="parameter reference">&amp;$file</tt></span>
   [, <span class="methodparam"><span class="type">int</span> <tt class="parameter reference">&amp;$line</tt></span>
  ]] )</div>

  <p class="para rdfs-comment">
   Vérifie si les en-têtes HTTP ont déjà été envoyés.
  </p>
  <p class="para">
   Vous ne pouvez plus envoyer d&#039;en-têtes avec la fonction <a href="function.header.php" class="function">header()</a>
   une fois que le bloc d&#039;en-tête a été fermé. En utilisant cette fonction, vous pouvez
   au moins éviter de voir s&#039;afficher les erreurs HTTP reliées. Une autre
   option consiste à utiliser le <a href="ref.outcontrol.php" class="link">contrôle de sortie</a>.
  </p>
 </div>


 <a name="function.headers-sent.parameters"></a><div class="refsect1 parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">
   </p><dl>

    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">file</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       Si les paramètres optionnels <i><tt class="parameter">file</tt></i>

       et <i><tt class="parameter">line</tt></i>
 sont fournis, <b>headers_sent()</b>
       va placer le nom du fichier source et le numéro de ligne qui ont débuté
       l&#039;affichage, dans les variables <i><tt class="parameter">file</tt></i>

       et <i><tt class="parameter">line</tt></i>
.
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">line</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       Le numéro de la ligne où la sortie a eu lieu.
      </p>
     </dd>

   
   </dl>
<p>
  </p>
 </div>


 <a name="function.headers-sent.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   <b>headers_sent()</b> retourne <b><tt class="constant">FALSE</tt></b> si aucun en-tête
   n&#039;a été envoyé, ou <b><tt class="constant">TRUE</tt></b> sinon.
  </p>
 </div>


 <a name="function.headers-sent.changelog"></a><div class="refsect1 changelog">
  <h3 class="title">Historique</h3>
  <p class="para">
   </p><table class="doctable informaltable">
   
     <thead valign="middle">
      <tr valign="middle">
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody valign="middle" class="tbody">
      <tr valign="middle">
       <td align="left">4.3.0</td>
       <td align="left">
        Ajout des paramètres optionnels <i><tt class="parameter">file</tt></i>
 et
        <i><tt class="parameter">line</tt></i>
.
       </td>
      </tr>

     </tbody>
   
   </table>
<p>
  </p>
 </div>


 <a name="function.headers-sent.examples"></a><div class="refsect1 examples">
  <h3 class="title">Exemples</h3>
  <p class="para">
   </p><div class="example">
    <p><b>Exemple #1 Exemple avec <b>headers_sent()</b></b></p>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;Si&nbsp;aucun&nbsp;en-tête&nbsp;n'a&nbsp;été&nbsp;envoyé,&nbsp;envoyons-en&nbsp;un<br /></span><span style="color: #007700">if&nbsp;(!</span><span style="color: #0000BB">headers_sent</span><span style="color: #007700">())&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">'Location:&nbsp;http://www.example.com/'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;exit;<br />}<br /><br /></span><span style="color: #FF8000">//&nbsp;Voici&nbsp;un&nbsp;exemple&nbsp;d'utilisation&nbsp;des&nbsp;paramètres&nbsp;optionnels&nbsp;de&nbsp;fichier&nbsp;et&nbsp;de&nbsp;ligne<br />//&nbsp;disponibles&nbsp;depuis&nbsp;PHP&nbsp;4.3.0.&nbsp;Notez&nbsp;que&nbsp;$filename&nbsp;et&nbsp;$linenum&nbsp;sont<br />//&nbsp;transmis&nbsp;pour&nbsp;utilisation&nbsp;ultérieure.&nbsp;Ne&nbsp;les&nbsp;assignez&nbsp;pas&nbsp;avant&nbsp;de&nbsp;les&nbsp;utiliser.<br /></span><span style="color: #007700">if&nbsp;(!</span><span style="color: #0000BB">headers_sent</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$linenum</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">'Location:&nbsp;http://www.example.com/'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;exit;<br /><br /></span><span style="color: #FF8000">//&nbsp;Vous&nbsp;allez&nbsp;probablement&nbsp;déclencher&nbsp;une&nbsp;erreur&nbsp;ici<br /></span><span style="color: #007700">}&nbsp;else&nbsp;{<br /><br />&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Les&nbsp;en-têtes&nbsp;ont&nbsp;déjà&nbsp;été&nbsp;envoyés,&nbsp;depuis&nbsp;le&nbsp;fichier&nbsp;</span><span style="color: #0000BB">$filename</span><span style="color: #DD0000">&nbsp;à&nbsp;la&nbsp;ligne&nbsp;</span><span style="color: #0000BB">$linenum</span><span style="color: #DD0000">\n"&nbsp;</span><span style="color: #007700">.<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"Il&nbsp;est&nbsp;donc&nbsp;impossible&nbsp;de&nbsp;vous&nbsp;rediriger&nbsp;automatiquement,&nbsp;aussi&nbsp;veuillez<br />&nbsp;&nbsp;&nbsp;cliquez&nbsp;&lt;a&nbsp;href=\"http://www.example.com\"&gt;ici&lt;/a&gt;.\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;exit;<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div><p>
  </p>
 </div>


 <a name="function.headers-sent.seealso"></a><div class="refsect1 seealso">
  <h3 class="title">Voir aussi</h3>
  <p class="para">
   </p><ul class="simplelist">
    <li class="member"><a href="function.ob-start.php" class="function" rel="rdfs-seeAlso">ob_start()</a> - Enclenche la tamporisation de sortie</li>
    <li class="member"><a href="function.trigger-error.php" class="function" rel="rdfs-seeAlso">trigger_error()</a> - Déclenche une erreur utilisateur</li>
    <li class="member"><a href="function.headers-list.php" class="function" rel="rdfs-seeAlso">headers_list()</a> - Retourne la liste des en-têtes de réponse du script courant</li>
    <li class="member">
     <a href="function.header.php" class="function" rel="rdfs-seeAlso">header()</a> - Envoie un en-tête HTTPpour plus de détails sur les
     tenants et aboutissants.
    </li>
   </ul><p>
  </p>
 </div>


</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites