<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.errorfunc.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'fr',
  ),
  'this' => 
  array (
    0 => 'function.error-log.php',
    1 => 'error_log',
    2 => 'Envoie un message d\'erreur vers le gestionnaire d\'erreurs d&eacute;fini',
  ),
  'up' => 
  array (
    0 => 'ref.errorfunc.php',
    1 => 'Fonctions sur la gestion des erreurs',
  ),
  'prev' => 
  array (
    0 => 'function.error-get-last.php',
    1 => 'error_get_last',
  ),
  'next' => 
  array (
    0 => 'function.error-reporting.php',
    1 => 'error_reporting',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/errorfunc/functions/error-log.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.error-log" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">error_log</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">error_log</span> &mdash; <span class="dc-title">Envoie un message d&#039;erreur vers le gestionnaire d&#039;erreurs défini</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.error-log-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>error_log</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$message</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$message_type</code><span class="initializer"> = 0</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$destination</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$additional_headers</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span><br>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Envoie un message d&#039;erreur à l&#039;historique d&#039;erreur
   du serveur web ou à un fichier.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.error-log-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">message</code></dt>
     <dd>
      <p class="para">
       Le message d&#039;erreur qui doit être stocké.
      </p>
     </dd>
    
    
     <dt><code class="parameter">message_type</code></dt>
     <dd>
      <p class="para">
       Spécifie la destination du message d&#039;erreur. 
       Les types possibles de messages sont :
      </p>
      <p class="para">
       <table class="doctable table">
        <caption><strong>Types de journalisation de <span class="function"><strong>error_log()</strong></span></strong></caption>
        
         <tbody class="tbody">
          <tr>
           <td>0</td>
           <td>
            <code class="parameter">message</code> est envoyé à l&#039;historique
            PHP, qui est basé sur l&#039;historique système ou un fichier,
            en fonction de la configuration de <a href="errorfunc.configuration.php#ini.error-log" class="link">error_log</a>. C&#039;est l&#039;option par défaut.
           </td>
          </tr>

          <tr>
           <td>1</td>
           <td>
            <code class="parameter">message</code> est envoyé par email à
            l&#039;adresse <code class="parameter">destination</code>. C&#039;est le seul type qui
            utilise le quatrième paramètre
            <code class="parameter">additional_headers</code>.
           </td>
          </tr>

          <tr>
           <td>2</td>
           <td>
            N&#039;est plus une option.
           </td>
          </tr>

          <tr>
           <td>3</td>
           <td>
            <code class="parameter">message</code> est ajouté au fichier
            <code class="parameter">destination</code>. Aucune nouvelle ligne
            (retour chariot) n&#039;est automatiquement ajoutée à la fin de la chaîne
            <code class="parameter">message</code>.
           </td>
          </tr>

          <tr>
           <td>4</td>
           <td>
           <code class="parameter">message</code> est envoyé directement au gestionnaire
           de journalisation SAPI.
           </td>
          </tr>

         </tbody>
        
       </table>

      </p>
     </dd>
    
    
     <dt><code class="parameter">destination</code></dt>
     <dd>
      <p class="para">
       La destination. Cela dépend du paramètre
       <code class="parameter">message_type</code> décrit ci-dessus.
      </p>
     </dd>
    
    
     <dt><code class="parameter">additional_headers</code></dt>
     <dd>
      <p class="para">
       Les en-têtes supplémentaires. Ils sont utilisés lorsque le paramètre
       <code class="parameter">message_type</code> est défini à 
       <code class="literal">1</code>. Ce type de message utilise la même fonction interne
       que la fonction <span class="function"><a href="function.mail.php" class="function">mail()</a></span>.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.error-log-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   Cette fonction retourne <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> en cas de succès ou <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> si une erreur survient.
   Si <code class="parameter">message_type</code> est zéro, alors cette fonction retourne toujours <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>,
   peu importe si l&#039;erreur a pu être enregistrée dans le journal d&#039;événements.
  </p>
 </div>

 
 <div class="refsect1 changelog" id="refsect1-function.error-log-changelog">
  <h3 class="title">Historique</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">destination</code> et 
       <code class="parameter">additional_headers</code>
       sont désormais nullables.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.error-log-examples">
  <h3 class="title">Exemples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Exemple #1 Exemples avec <span class="function"><strong>error_log()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// Envoie une notification par l'historique du serveur web,<br />// si la connexion à la base de données est impossible.<br /></span><span style="color: #007700">if (!</span><span style="color: #0000BB">Ora_Logon</span><span style="color: #007700">(</span><span style="color: #0000BB">$username</span><span style="color: #007700">, </span><span style="color: #0000BB">$password</span><span style="color: #007700">)) {<br />  </span><span style="color: #0000BB">error_log</span><span style="color: #007700">(</span><span style="color: #DD0000">"Base Oracle indisponible !"</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #FF8000">// Indiquer à l'administrateur, par email, qu'il n'y a plus de FOO<br /></span><span style="color: #007700">if (!(</span><span style="color: #0000BB">$foo </span><span style="color: #007700">= </span><span style="color: #0000BB">allocate_new_foo</span><span style="color: #007700">())) {<br />  </span><span style="color: #0000BB">error_log</span><span style="color: #007700">(</span><span style="color: #DD0000">"Aya!, Il ne reste plus de FOO disponibles !"</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">,<br />  </span><span style="color: #DD0000">"operateur@example.com"</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #FF8000">// D'autres manières d'appeler error_log():<br /></span><span style="color: #0000BB">error_log</span><span style="color: #007700">(</span><span style="color: #DD0000">"Grosse bourde !"</span><span style="color: #007700">, </span><span style="color: #0000BB">3</span><span style="color: #007700">, </span><span style="color: #DD0000">"/var/tmp/mes-erreurs.log"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

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


 <div class="refsect1 notes" id="refsect1-function.error-log-notes">
  <h3 class="title">Notes</h3>
  <div class="warning"><strong class="warning">Avertissement</strong>
   <p class="simpara">
    La fonction <span class="function"><strong>error_log()</strong></span> n&#039;est pas sûre pour les données binaires.
    Le paramètre <code class="parameter">message</code> sera tronqué par un caractère nul.
   </p>
  </div>
  <div class="tip"><strong class="tip">Astuce</strong>
   <p class="simpara">
    Le paramètre <code class="parameter">message</code> ne doit pas contenir de caractère
    nul. Il est à noter que le paramètre <code class="parameter">message</code> peut être envoyé
    vers un fichier, un mail, syslog, etc. Il convient d&#039;utiliser les fonctions appropriées de
    conversion/échappement, <span class="function"><a href="function.base64-encode.php" class="function">base64_encode()</a></span>, <span class="function"><a href="function.rawurlencode.php" class="function">rawurlencode()</a></span>
    ou <span class="function"><a href="function.addslashes.php" class="function">addslashes()</a></span> avant d&#039;appeler la fonction <span class="function"><strong>error_log()</strong></span>.
   </p>
  </div>
 </div>


</div><?php manual_footer($setup); ?>