[PHP-DOC] cvs: phpdoc /fr chapters.ent /fr/functions errorfunc.xml From: Egon Schmid (eschmid <email protected>)
Date: 10/16/00

eschmid Mon Oct 16 05:45:54 2000 EDT

  Added files:
    /phpdoc/fr/functions errorfunc.xml

  Modified files:
    /phpdoc/fr chapters.ent
  Log:
  First part to make the French manual buildable.
  
Index: phpdoc/fr/chapters.ent
diff -u phpdoc/fr/chapters.ent:1.7 phpdoc/fr/chapters.ent:1.8
--- phpdoc/fr/chapters.ent:1.7 Sun Oct 15 11:57:04 2000
+++ phpdoc/fr/chapters.ent Mon Oct 16 05:45:52 2000
@@ -43,13 +43,15 @@
 <!ENTITY reference.dbase SYSTEM "functions/dbase.xml">
 <!ENTITY reference.dbm SYSTEM "functions/dbm.xml">
 <!ENTITY reference.dir SYSTEM "functions/dir.xml">
-<!ENTITY reference.dl SYSTEM "functions/dl.xml">
+<!-- ENTITY reference.dl SYSTEM "functions/dl.xml" -->
 <!ENTITY reference.domxml SYSTEM "functions/domxml.xml">
+<!ENTITY reference.errorfunc SYSTEM "functions/errorfunc.xml">
 <!ENTITY reference.exec SYSTEM "functions/exec.xml">
 <!ENTITY reference.fdf SYSTEM "functions/fdf.xml">
 <!ENTITY reference.filepro SYSTEM "functions/filepro.xml">
 <!ENTITY reference.filesystem SYSTEM "functions/filesystem.xml">
 <!ENTITY reference.ftp SYSTEM "functions/ftp.xml">
+<!ENTITY reference.funchand SYSTEM "functions/funchand.xml">
 <!ENTITY reference.gettext SYSTEM "functions/gettext.xml">
 <!ENTITY reference.http SYSTEM "functions/http.xml">
 <!ENTITY reference.hw SYSTEM "functions/hw.xml">
@@ -83,6 +85,7 @@
 <!ENTITY reference.readline SYSTEM "functions/readline.xml">
 <!ENTITY reference.recode SYSTEM "functions/recode.xml">
 <!ENTITY reference.regex SYSTEM "functions/regex.xml">
+<!ENTITY reference.satellite SYSTEM "functions/satellite.xml">
 <!ENTITY reference.sem SYSTEM "functions/sem.xml">
 <!ENTITY reference.session SYSTEM "functions/session.xml">
 <!ENTITY reference.shmop SYSTEM "functions/shmop.xml">

Index: phpdoc/fr/functions/errorfunc.xml
+++ phpdoc/fr/functions/errorfunc.xml
 <reference id="ref.errorfunc">
  <title>Error Handling and Logging Functions</title>
  <titleabbrev>Errors and Logging</titleabbrev>

  <partintro>
   <para>
    These are functions dealing with error handling and logging. They
    allow you to define your own error handling rules, as well as modify
    the way the errors can be logged. This allows you to change and
    enhance error reporting to suit your needs.
   </para>
   <para>
    With the logging functions, you can send messages directly to other
    machines, to an email (or email to pager gateway!), to system logs,
    etc., so you can selectively log and monitor the most important parts
    of your applications and websites.
   </para>
   <para>
    The error reporting functions allow you to customize what level and
    kind of error feedback is given, ranging from simple notices to customized
    functions returned during errors.
   </para>
  </partintro>

  <refentry id="function.error-log">
   <refnamediv>
    <refname>error_log</refname>
    <refpurpose>Envoie un message d'erreur.</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
    <funcsynopsis>
     <funcdef>int <function>error_log</function></funcdef>
     <paramdef>string <parameter>message</parameter></paramdef>
     <paramdef>int <parameter>message_type</parameter></paramdef>
     <paramdef>string
      <parameter><optional>destination</optional></parameter>
     </paramdef>
     <paramdef>string
      <parameter><optional>extra_headers</optional></parameter>
     </paramdef>
    </funcsynopsis>
    <para>
      Envoie un message d'erreur dans les logs du serveur, sur un port
      <acronym>TCP</acronym>, ou bien &agrave; un fichier. Le premier param&egrave;tre,
      <parameter>message</parameter>, est le message qui doit &ecirc;tre envoy&eacute;.
      Le deuxi&egrave;me param&egrave;tre, <parameter>message_type</parameter> indique
      l'endroit o&uacute; le message doit aller:
     <table>
      <title>types de log <function>error_log</function></title>
      <tgroup cols="2">
       <tbody>
        <row>
         <entry>0</entry>
         <entry>
          Le message <parameter>message</parameter> est envoy&eacute; au syst&egrave;me de log
          du PHP, en utilisant la fonction syst&egrave;me de logs, en fonction de la
          configuration de l'option <link linkend="ini.error-log">error_log</link>.
        </entry>
        </row>
        <row>
         <entry>1</entry>
         <entry>
          <parameter>message</parameter>
           Le message est envoy&eacute; par mail &agrave; l'adresse donn&eacute;e dans le param&egrave;tre
           <parameter>destination</parameter>. C'est le seul moment o&uacute; le quatri&egrave;me
           param&egrave;tres, <parameter>extra_headers</parameter> est utilis&eacute;. Ce type de
           message utilise les m&ecirc;mes fonctions internes que la fonction
           <function>mail</function>.
         </entry>
        </row>
        <row>
         <entry>2</entry>
         <entry>
           Le message <parameter>message</parameter> est envoy&eacute; au travers de la
           connexion de d&eacute;buggage. Cette option est disponible uniquement si
           <link linkend="enable-debugger">&quot;remote debugging&quot;</link>
           a &eacute;t&eacute; activ&eacute;e. Dans ce cas, le param&egrave;tre <parameter>destination</parameter>
           sp&eacute;cifie le nom de l'h&ocirc;te ou l'adresse IP ainsi que, optionnellement,
           le num&eacute;ro de port de la socket recevant les informations de d&eacute;bugage.
         </entry>
        </row>
        <row>
         <entry>3</entry>
         <entry>
          Le message <parameter>message</parameter> est simplement &eacute;crit dans le fichier
          <parameter>destination</parameter>.
         </entry>
        </row>
       </tbody>
      </tgroup>
     </table></para>
    <para>
     <example role="php">
      <title>Exemple avec <function>error_log</function></title>
      <programlisting role="php">
// Envoie un message &agrave; l'administrateur si on ne peut
// pas se connecter &agrave; la base de donn&eacute;e.
if (!Ora_Logon($username, $password)) {
    error_log("Base de donn&eacute;es Oracle indisponible!", 0);
}

// Envoie un mail &agrave; l'administrateur.
if (!($foo = allocate_new_foo()) {
    error_log("Gros probl&egrave;me de connexion &agrave; la base!", 1,
              "operator <email protected>");
}

// Une autre mani&egrave;re d'appeler la fonction error_log():
error_log("Grosse bourde!", 2, "127.0.0.1:7000");
error_log("Grosse bourde!", 2, "loghost");
error_log("Grosse bourde!", 3, "/var/tmp/my-errors.log");
      </programlisting>
     </example>
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.error-reporting">
   <refnamediv>
    <refname>error_reporting</refname>
    <refpurpose>&eacute;tablit le niveau d'erreur &agrave; prendre en compte.</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
    <funcsynopsis>
     <funcdef>int <function>error_reporting</function></funcdef>
     <paramdef>int
      <parameter><optional>level</optional></parameter>
     </paramdef>
    </funcsynopsis>
    <para>
     &eacute;tablit le niveau d'erreur &agrave; prendre en compte et renvoie l'ancien niveau. Le
     niveau d'erreur est un champs de bits qui utilise les valeurs suivantes:
     (suivez les liens pour conna&icirc;tre les valeurs et leur signification)
     <table>
      <title><function>error_reporting</function> bit values</title>
      <tgroup cols="2">
       <thead>
        <row>
         <entry>Valeur</entry>
         <entry>Nom interne</entry>
        </row>
       </thead>
       <tbody>
        <row>
         <entry>1</entry>
         <entry>
          <link linkend="internal.e-error">E_ERROR</link>
         </entry>
        </row>
        <row>
         <entry>2</entry>
         <entry>
          <link linkend="internal.e-warning">E_WARNING</link>
         </entry>
        </row>
        <row>
         <entry>4</entry>
         <entry>
          <link linkend="internal.e-parse">E_PARSE</link>
         </entry>
        </row>
        <row>
         <entry>8</entry>
         <entry>
          <link linkend="internal.e-notice">E_NOTICE</link>
         </entry>
        </row>
        <row>
         <entry>16</entry>
         <entry>
          E_CORE_ERROR
         </entry>
        </row>
        <row>
         <entry>32</entry>
         <entry>
          E_CORE_WARNING
         </entry>
        </row>
       </tbody>
      </tgroup>
     </table>
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.restore-error-handler">
   <refnamediv>
    <refname>restore_error_handler</refname>
    <refpurpose>
     Restores the previous error handler function
    </refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
    <funcsynopsis>
     <funcprototype>
      <funcdef>void <function>restore_error_handler</function></funcdef>
      <paramdef>void</paramdef>
     </funcprototype>
    </funcsynopsis>
    <para>
     Used after changing the error handler function using
     <function>set_error_handler</function>, to revert to the previous error
     handler (which could be the built-in or a user defined function)
    </para>
    <para>
     See also <function>error_reporting</function>,
     <function>set_error_handler</function>,
     <function>trigger_error</function>, <function>user_error</function>
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.set-error-handler">
   <refnamediv>
    <refname>set_error_handler</refname>
    <refpurpose>
     Sets a user-defined error handler function.
    </refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
    <funcsynopsis>
     <funcprototype>
      <funcdef>string <function>set_error_handler</function></funcdef>
      <paramdef>string <parameter>error_handler</parameter></paramdef>
     </funcprototype>
    </funcsynopsis>
    <para>
     Sets a user function (<parameter>error_handler</parameter>) to handle
     errors in a script. Returns the previously defined error handler (if
     any), or false on error. This function can be used for defining your own
     way of handling errors during runtime, for example in applications in
     which you need to do cleanup of data/files when a critical error happens,
     or when you need to trigger an error under certain conditions (using
     <function>trigger_error</function>)
    </para>
    <para>
     The user function needs to accept 2 parameters: the error code, and a
     string describing the error. The example below shows the handling of
     internal execptions by triggering errors and handling them with a user
     defined function:
     <example>
      <title>
       Error handling with <function>set_error_handler</function> and
       <function>trigger_error</function>
      </title>
      <programlisting role="php">
&lt;?php

// redefine the user error constants - PHP 4 only
define (FATAL,E_USER_ERROR);
define (ERROR,E_USER_WARNING);
define (WARNING,E_USER_NOTICE);

// set the error reporting level for this script
error_reporting (FATAL + ERROR + WARNING);

// error handler function
function myErrorHandler ($errno, $errstr) {
    switch ($errno) {
    case FATAL:
    echo &quot;&lt;b&gt;FATAL&lt;/b&gt; [$errno] $errstr&lt;br&gt;\n&quot;;
    echo &quot; Fatal error in line &quot;.__LINE__.&quot; of file &quot;.__FILE__;
    echo &quot;, PHP &quot;.PHP_VERSION.&quot; (&quot;.PHP_OS.&quot;)&lt;br&gt;\n&quot;;
    echo &quot;Aborting...&lt;br&gt;\n&quot;;
    exit -1;
    break;
    case ERROR:
    echo &quot;&lt;b&gt;ERROR&lt;/b&gt; [$errno] $errstr&lt;br&gt;\n&quot;;
    break;
    case WARNING:
    echo &quot;&lt;b&gt;WARNING&lt;/b&gt; [$errno] $errstr&lt;br&gt;\n&quot;;
    break;
    default:
    echo &quot;Unkown error type: [$errno] $errstr&lt;br&gt;\n&quot;;
    break;
    }
}

// function to test the error handling
function scale_by_log ($vect, $scale) {
    if ( !is_numeric($scale) || $scale &lt;= 0 )
    trigger_error(&quot;log(x) for x &lt;= 0 is undefined, you used: scale = $scale&quot;,
      FATAL);
    if (!is_array($vect)) {
    trigger_error(&quot;Incorrect input vector, array of values expected&quot;, ERROR);
    return null;
    }
    for ($i=0; $i&lt;count($vect); $i++) {
    if (!is_numeric($vect[$i]))
    trigger_error(&quot;Value at position $i is not a number, using 0 (zero)&quot;,
      WARNING);
    $temp[$i] = log($scale) * $vect[$i];
    }
    return $temp;
}

// set to the user defined error handler
$old_error_handler = set_error_handler(&quot;myErrorHandler&quot;);

// trigger some errors, first define a mixed array with a non-numeric item
echo &quot;vector a\n&quot;;
$a = array(2,3,&quot;foo&quot;,5.5,43.3,21.11);
print_r($a);

// now generate second array, generating a warning
echo &quot;----\nvector b - a warning (b = log(PI) * a)\n&quot;;
$b = scale_by_log($a, M_PI);
print_r($b);

// this is trouble, we pass a string instead of an array
echo &quot;----\nvector c - an error\n&quot;;
$c = scale_by_log(&quot;not array&quot;,2.3);
var_dump($c);

// this is a critical error, log of zero or negative number is undefined
echo &quot;----\nvector d - fatal error\n&quot;;
$d = scale_by_log($a, -2.5);

?&gt;
      </programlisting>
     </example>
     And when you run this sample script, the output will be
     <informalexample>
      <programlisting>
vector a
Array
(
    [0] =&gt; 2
    [1] =&gt; 3
    [2] =&gt; foo
    [3] =&gt; 5.5
    [4] =&gt; 43.3
    [5] =&gt; 21.11
)

----
vector b - a warning (b = log(PI) * a)
&lt;b&gt;WARNING&lt;/b&gt; [1024] Value at position 2 is not a number, using 0 (zero)&lt;br&gt;
Array
(
    [0] =&gt; 2.2894597716988
    [1] =&gt; 3.4341896575482
    [2] =&gt; 0
    [3] =&gt; 6.2960143721717
    [4] =&gt; 49.566804057279
    [5] =&gt; 24.165247890281
)
----
vector c - an error
&lt;b&gt;ERROR&lt;/b&gt; [512] Incorrect input vector, array of values expected&lt;br&gt;
NULL
----
vector d - fatal error
&lt;b&gt;FATAL&lt;/b&gt; [256] log(x) for x &lt;= 0 is undefined, you used: scale = -2.5&lt;br&gt;
  Fatal error in line 16 of file trigger_error.php, PHP 4.0.1pl2 (Linux)&lt;br&gt;
Aborting...&lt;br&gt;
      </programlisting>
     </informalexample>
    </para>
    <para>
     See also <function>error_reporting</function>,
     <function>restore_error_handler</function>,
     <function>trigger_error</function>, <function>user_error</function>
    </para>
   </refsect1>
  </refentry>

<refentry id="function.trigger-error"> <refnamediv> <refname>trigger_error</refname> <refpurpose> Generates a user-level error/warning/notice message </refpurpose> </refnamediv> <refsect1> <title>Description</title> <funcsynopsis> <funcprototype> <funcdef>void <function>trigger_error</function></funcdef> <paramdef>string <parameter>error_msg</parameter></paramdef> <paramdef>int <parameter><optional>error_type</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> Used to trigger a user error condition, it can be used by in conjunction with the built-in error handler, or with a user defined function that has been set as the new error handler (<function>set_error_handler</function>). This function is useful when you need to generate a particular response to an exception at runtime. For example: <informalexample> <programlisting> if (assert ($divisor == 0)) trigger_error ("Cannot divide by zero", E_USER_ERROR); </programlisting> </informalexample> <note> <para> See <function>set_error_handler</function> for a more extensive example. </para> </note> </para> <para> See also <function>error_reporting</function>, <function>set_error_handler</function>, <function>restore_error_handler</function>, <function>user_error</function> </para> </refsect1> </refentry>

<refentry id="function.user-error"> <refnamediv> <refname>user_error</refname> <refpurpose> Generates a user-level error/warning/notice message </refpurpose> </refnamediv> <refsect1> <title>Description</title> <funcsynopsis> <funcprototype> <funcdef>void <function>user_error</function></funcdef> <paramdef>string <parameter>error_msg</parameter></paramdef> <paramdef>int <parameter><optional>error_type</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> This is an alias for the function <function>trigger_error</function>. </para> <para> See also <function>error_reporting</function>, <function>set_error_handler</function>, <function>restore_error_handler</function>, and <function>trigger_error</function> </para> </refsect1> </refentry>

</reference>

<!-- 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 sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: -->